From d63567531d36faf3718fd00fa1f754747baec387 Mon Sep 17 00:00:00 2001 From: Elias Dorneles Date: Tue, 21 Apr 2015 11:30:48 -0300 Subject: [PATCH] change data extraction in crawl example to be consistent with tutorial, removed statement implying mandatory usage of Item --- docs/intro/tutorial.rst | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/intro/tutorial.rst b/docs/intro/tutorial.rst index a08eb59d6..ab2302154 100644 --- a/docs/intro/tutorial.rst +++ b/docs/intro/tutorial.rst @@ -387,7 +387,7 @@ in your output. Run:: Using our item -------------- -:class:`~scrapy.item.Item` objects are custom python dicts; you can access the +:class:`~scrapy.item.Item` objects are custom Python dicts; you can access the values of their fields (attributes of the class we defined earlier) using the standard dict syntax like:: @@ -396,9 +396,8 @@ standard dict syntax like:: >>> item['title'] 'Example title' -Spiders are expected to return their scraped data inside -:class:`~scrapy.item.Item` objects. So, in order to return the data we've -scraped so far, the final code for our Spider would be like this:: +So, in order to return the data we've scraped so far, the final code for our +Spider would be like this:: import scrapy @@ -491,9 +490,11 @@ for it:: def parse_articles_follow_next_page(self, response): for article in response.xpath("//article"): - yield { - ... extract article data here - } + item = ArticleItem() + + ... extract article data here + + yield item next_page = response.css("ul.navigation > li.next-page > a::attr('href')") if next_page: