Scrapy 创建一个项目
要从网页中取消数据,首先需要创建Scrapy项目,您将在其中存储代码。
要创建一个新目录,请运行以下命令:
scrapy startproject first_scrapy
上面的代码将创建一个名为first_scrapy的目录,它将包含以下结构:
first_scrapy/ scrapy.cfg # deploy configuration file first_scrapy/ # project's Python module, you'll import your code from here __init__.py items.py # project items file pipelines.py # project pipelines file settings.py # project settings file spiders/ # a directory where you'll later put your spiders __init__.py
项目是用于收集从网站报废的数据的容器。你必须通过定义你的物品来启动你的蜘蛛。要定义项目,请编辑在 first_scrapy (自定义目录)目录下找到的 items.py 文件。该 items.py 看起来如下:i ...