1.創建項目
* * * * *
**`scrapy startproject tutorial`**
tutorial為項目名稱,可自行修改
這將創建一個tutorial包含以下內容的目錄:
tutorial/
scrapy.cfg # deploy configuration file
tutorial/ # project's Python module, you'll import your code from here
__init__.py
items.py # project items definition file
middlewares.py # project middlewares file
pipelines.py # project pipelines file
settings.py # project settings file
spiders/ # a directory where you'll later put your spiders
__init__.py
* * * * *
創建項目
scrapy genspider mydomain mydomain.com
* * * * *
2.運行爬蟲
轉到項目頂級目錄下運行
`scrapy crawl spider_name`
* * * * *
scrapy shell "http://quotes.toscrape.com/page/1/"
* * * * *
scrapy crawl quotes -o quotes.json
* * * * *