Scrapy 0.24 Documentation
prompt to check pip is installed correctly: pip --version At this point Python 2.7 and pip package manager must be working, let’s install Scrapy: pip install Scrapy Ubuntu 9.10 or above Don’t use the python-scrapy More important, if you type response.selector you will access a selector object you can use to query the response, and convenient shortcuts like response.xpath() and response.css() mapping to response occur. xpath(query) Find nodes matching the xpath query and return the result as a SelectorList instance with all elements flattened. List elements implement Selector interface too. query is a string0 码力 | 298 页 | 544.11 KB | 1 年前3Scrapy 0.24 Documentation
to check pip is installed correctly: pip --version • At this point Python 2.7 and pip package manager must be working, let’s install Scrapy: pip install Scrapy Ubuntu 9.10 or above Don’t use the python-scrapy 6 More important, if you type response.selector you will access a selector object you can use to query the response, and convenient shortcuts like response.xpath() and response.css() mapping to response occur. xpath(query) Find nodes matching the xpath query and return the result as a SelectorList instance with all ele- ments flattened. List elements implement Selector interface too. query is a string0 码力 | 222 页 | 988.92 KB | 1 年前3Scrapy 1.1 Documentation
prompt to check pip is installed correctly: pip --version At this point Python 2.7 and pip package manager must be working, let’s install Scrapy: pip install Scrapy Note Python 3 is not supported on Windows conflict with the rest of your system. Here’s how to do it using the homebrew [http://brew.sh/] package manager: Install homebrew [http://brew.sh/] following the instructions in http://brew.sh/ Update your PATH ['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 0 码力 | 322 页 | 582.29 KB | 1 年前3Scrapy 1.2 Documentation
prompt to check pip is installed correctly: pip --version At this point Python 2.7 and pip package manager must be working, let’s install Scrapy: pip install Scrapy Note Python 3 is not supported on Windows conflict with the rest of your system. Here’s how to do it using the homebrew [http://brew.sh/] package manager: Install homebrew [http://brew.sh/] following the instructions in http://brew.sh/ Update your PATH ['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 0 码力 | 330 页 | 548.25 KB | 1 年前3Scrapy 1.3 Documentation
conflict with the rest of your system. Here’s how to do it using the homebrew [http://brew.sh/] package manager: Install homebrew [http://brew.sh/] following the instructions in http://brew.sh/ Update your PATH ['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 0 码力 | 339 页 | 555.56 KB | 1 年前3Scrapy 1.2 Documentation
to check pip is installed correctly: pip --version • At this point Python 2.7 and pip package manager must be working, let’s install Scrapy: pip install Scrapy Note: Python 3 is not supported on Windows that doesn’t conflict with the rest of your system. Here’s how to do it using the homebrew package manager: – Install homebrew following the instructions in http://brew.sh/ – Update your PATH variable to ['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 0 码力 | 266 页 | 1.10 MB | 1 年前3Scrapy 1.1 Documentation
to check pip is installed correctly: pip --version • At this point Python 2.7 and pip package manager must be working, let’s install Scrapy: pip install Scrapy 8 Chapter 2. First steps Scrapy Documentation that doesn’t conflict with the rest of your system. Here’s how to do it using the homebrew package manager: – Install homebrew following the instructions in http://brew.sh/ – Update your PATH variable to Documentation, Release 1.1.3 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 0 码力 | 260 页 | 1.12 MB | 1 年前3Scrapy 1.3 Documentation
that doesn’t conflict with the rest of your system. Here’s how to do it using the homebrew package manager: – Install homebrew following the instructions in http://brew.sh/ – Update your PATH variable to ['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 0 码力 | 272 页 | 1.11 MB | 1 年前3Scrapy 0.20 Documentation
parse(self, response): sel = Selector(response) # Using XPath query print sel.xpath('//p') # Using CSS query print sel.css('p') # Nesting queries print sel.x occur. xpath(query) Find nodes matching the xpath query and return the result as a SelectorList instance with all elements flattened. List elements implement Selector interface too. query is a string string containing the XPATH query to apply. css(query) Apply the given CSS selector and return a SelectorList instance. query is a string containing the CSS selector to apply. In the background, CSS queries0 码力 | 276 页 | 564.53 KB | 1 年前3Scrapy 0.22 Documentation
MySpider(Spider): # ... def parse(self, response): sel = Selector(response) # Using XPath query print sel.xpath(’//p’) # Using CSS query print sel.css(’p’) # Nesting queries print sel.xpath(’//div[@foo="bar"]’).css(’span#bold’) 22.0 xpath(query) Find nodes matching the xpath query and return the result as a SelectorList instance with all ele- ments flattened. List elements implement Selector interface too. query is a string string containing the XPATH query to apply. css(query) Apply the given CSS selector and return a SelectorList instance. query is a string containing the CSS selector to apply. In the background, CSS queries0 码力 | 199 页 | 926.97 KB | 1 年前3
共 62 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7