Link to previous chapter: 环境设置-1
2. 开始第一个 Scarpy 项目
2.1 创建项目
因为我们本地并没有scrapy的executable,需要启动一个ad-hoc的容器并在容器里面操作, 进入容器:
1
| > docker-compose run --rm scrapy
|
现在开始创建我们的project
1 2 3
| > cd /app > scrapy startproject app_trend > cd app_trend
|
这样子会生成一个 app_trend
folder, 其中主要的文件目录是:
1 2 3 4 5 6 7 8 9 10 11
| 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
|
我们将会在 spiders/
folder 里面编写我们自己的 spider