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
* * * * *