Scrapy 1.3 Documentation['Quotes to Scrape'] There are two things to note here: one is that we’ve added ::text to the CSS query, to mean we want to select only the text elements directly insideelement. If we don’t specify the quote HTML elements with: >>> response.css("div.quote") Each of the selectors returned by the query above allows us to run further queries over their sub-elements. Let’s assign the first selector to Request(next_page, callback=self.parse) def parse_author(self, response): def extract_with_css(query): return response.css(query).extract_first().strip() yield { 'name': extract_with_css('h3.author-title::text') 0 码力 | 272 页 | 1.11 MB | 1 年前3
 Scrapy 1.3 Documentation['Quotes to Scrape'] There are two things to note here: one is that we’ve added ::text to the CSS query, to mean we want to select only the text elements directly insideelement. If we don’t specify the quote HTML elements with: >>> response.css("div.quote") Each of the selectors returned by the query above allows us to run further queries over their sub-elements. Let’s assign the first selector to callback=self.parse) def parse_author(self, response): def extract_with_css(query): return response.css(query).extract_first().strip() yield { 'name': extract_with_css('h3 0 码力 | 339 页 | 555.56 KB | 1 年前3
 Scrapy 1.4 Documentation['Quotes to Scrape'] There are two things to note here: one is that we’ve added ::text to the CSS query, to mean we want to select only the text elements directly insideelement. If we don’t specify the quote HTML elements with: >>> response.css("div.quote") Each of the selectors returned by the query above allows us to run further queries over their sub-elements. Let’s assign the first selector to response.follow(href, self.parse) def parse_author(self, response): def extract_with_css(query): return response.css(query).extract_first().strip() yield { 'name': extract_with_css('h3.author-title::text') 0 码力 | 281 页 | 1.15 MB | 1 年前3
 Scrapy 1.4 Documentation['Quotes to Scrape'] There are two things to note here: one is that we’ve added ::text to the CSS query, to mean we want to select only the text elements directly insideelement. If we don’t specify the quote HTML elements with: >>> response.css("div.quote") Each of the selectors returned by the query above allows us to run further queries over their sub-elements. Let’s assign the first selector to self.parse) def parse_author(self, response): def extract_with_css(query): return response.css(query).extract_first().strip() yield { 'name': extract_with_css('h3 0 码力 | 353 页 | 566.69 KB | 1 年前3
 Scrapy 1.4 Documentation['Quotes to Scrape'] There are two things to note here: one is that we’ve added ::text to the CSS query, to mean we want to select only the text elements directly insideelement. If we don’t specify the quote HTML elements with: >>> response.css("div.quote") Each of the selectors returned by the query above allows us to run further queries over their sub-elements. Let’s assign the first selector to self.parse) def parse_author(self, response): def extract_with_css(query): return response.css(query).extract_first().strip() yield { 'name': extract_with_css('h3 0 码力 | 394 页 | 589.10 KB | 1 年前3
 Scrapy 1.5 Documentation['Quotes to Scrape'] There are two things to note here: one is that we’ve added ::text to the CSS query, to mean we want to select only the text elements directly insideelement. If we don’t specify the quote HTML elements with: >>> response.css("div.quote") Each of the selectors returned by the query above allows us to run further queries over their sub-elements. Let’s assign the first selector to response.follow(href, self.parse) def parse_author(self, response): def extract_with_css(query): return response.css(query).extract_first().strip() yield { 'name': extract_with_css('h3.author-title::text') 0 码力 | 285 页 | 1.17 MB | 1 年前3
 Scrapy 1.6 Documentation['Quotes to Scrape'] There are two things to note here: one is that we’ve added ::text to the CSS query, to mean we want to select only the text elements directly insideelement. If we don’t specify the quote HTML elements with: >>> response.css("div.quote") Each of the selectors returned by the query above allows us to run further queries over their sub-elements. Let’s assign the first selector to response.follow(href, self.parse) def parse_author(self, response): def extract_with_css(query): return response.css(query).get(default='').strip() yield { 'name': extract_with_css('h3.author-title::text') 0 码力 | 295 页 | 1.18 MB | 1 年前3
 Scrapy 1.5 Documentation['Quotes to Scrape'] There are two things to note here: one is that we’ve added ::text to the CSS query, to mean we want to select only the text elements directly insideelement. If we don’t specify the quote HTML elements with: >>> response.css("div.quote") Each of the selectors returned by the query above allows us to run further queries over their sub-elements. Let’s assign the first selector to self.parse) def parse_author(self, response): def extract_with_css(query): return response.css(query).extract_first().strip() yield { 'name': extract_with_css('h3 0 码力 | 361 页 | 573.24 KB | 1 年前3
 Scrapy 1.7 Documentation['Quotes to Scrape'] There are two things to note here: one is that we’ve added ::text to the CSS query, to mean we want to select only the text elements directly insideelement. If we don’t specify the quote HTML elements with: >>> response.css("div.quote") Each of the selectors returned by the query above allows us to run further queries over their sub-elements. Let’s assign the first selector to response.follow(href, self.parse) def parse_author(self, response): def extract_with_css(query): return response.css(query).get(default='').strip() yield { 'name': extract_with_css('h3.author-title::text') 0 码力 | 306 页 | 1.23 MB | 1 年前3
 Scrapy 1.8 Documentation['Quotes to Scrape'] There are two things to note here: one is that we’ve added ::text to the CSS query, to mean we want to select only the text elements directly insideelement. If we don’t specify the quote HTML elements with: >>> response.css("div.quote") Each of the selectors returned by the query above allows us to run further queries over their sub-elements. Let’s assign the first selector to response.follow(href, self.parse) def parse_author(self, response): def extract_with_css(query): return response.css(query).get(default='').strip() yield { 'name': extract_with_css('h3.author-title::text') 0 码力 | 335 页 | 1.44 MB | 1 年前3
共 62 条
- 1
 - 2
 - 3
 - 4
 - 5
 - 6
 - 7
 













