Scrapy Documentation, Release 0.17.0
[dmoz] DEBUG: Scraped from <200 http://www.dmoz.org/Computers/Programming/Languages/Python/Books/>
{’desc’: [u’ - By David Mertz; Addison Wesley. Book in progress, full text, ASCII format. Asks for feedback. [author website, Gnosis Software, Inc.\n],
’link’: [u’http://gnosis.cx/TPiP/’],
’title’: [u’Text Processing in Python’]}
[dmoz] DEBUG: Scraped from <200 http://www.dmoz.org/Computers/Programming/Languages/Python/Books/>
{’desc’: [u’ - By Sean McGrath; Prentice Hall PTR, 2000, ISBN 0130211192, has CD-ROM. Methods to build XML applications fast, Python tutorial, DOM and SAX, new Pyxie open source XML processing library. [Prentice Hall PTR]\n’],
’link’: [u’http://www.informit.com/store/product.aspx?isbn=0130211192’],
’title’: [u’XML Processing with Python’]}
2.3.4 Storing the scraped data
The simplest way to store the scraped data is by using the Feed exports, with the following command:
scrapy crawl dmoz -o items.json -t json
That will generate a items.json file containing all scraped items, serialized in JSON.
In small projects (like the one in this tutorial), that should be enough. However, if you want to perform more complex
things with the scraped items, you can write an Item Pipeline. As with Items, a placeholder file for Item Pipelines
has been set up for you when the project is created, in tutorial/pipelines.py. Though you don’t need to
implement any item pipeline if you just want to store the scraped items.
2.3.5 Next steps
This tutorial covers only the basics of Scrapy, but there’s a lot of other features not mentioned here. Check the What
else? section in Scrapy at a glance chapter for a quick overview of the most important ones.
Then, we recommend you continue by playing with an example project (see Examples), and then continue with the
section Basic concepts.
2.4 Examples
The best way to learn is with examples, and Scrapy is no exception. For this reason, there is an example Scrapy project
named dirbot, that you can use to play and learn more about Scrapy. It contains the dmoz spider described in the
tutorial.
This dirbot project is available at: https://github.com/scrapy/dirbot
It contains a README file with a detailed description of the project contents.
If you’re familiar with git, you can checkout the code. Otherwise you can download a tarball or zip file of the project
by clicking on Downloads.
The scrapy tag on Snipplr is used for sharing code snippets such as spiders, middlewares, extensions, or scripts. Feel
free (and encouraged!) to share any code there.
Scrapy at a glance Understand what Scrapy is and how it can help you.
Installation guide Get Scrapy installed on your computer.
Scrapy Tutorial Write your first Scrapy project.
Examples Learn more by playing with a pre-made Scrapy project.
16 Chapter 2. First steps