创建Scrapy项目
安装Scrapy,如果是用PIP安装,在终端输入命令如下:
pip install scrapy
在安装的过程中,可能会提示错误,可能会有某些依赖包无法安装,这时需要单独安装依赖包后再运行上面的命令安装Scrapy。
在使用Scrapy项目之前,我们必须创建一个Scrapy工程,依旧是在终端输入命令:
scrapy startproject tutorial # tutorial:这里是项目名字
这个时候我们就会发现创建了一个tutorial文件夹,里面包含:
tutorial/
scrapy.cfg # 项目的配置文件。
tutorial/ # 项目的Python模块,将会从这里引用代码。
__init__.py
items.py # 项目的目标文件。用于定义项目的目标实体
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