1

Python爬虫编程思想(146):创建和使用Scrapy工程

 1 year ago
source link: https://blog.csdn.net/nokiaguy/article/details/124778211
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Python爬虫编程思想(146):创建和使用Scrapy工程

        Scrapy框架提供了一个scrapy命令用来建立Scrapy工程,可以使用下面的命令建立一个名为myscrapy是Scrapy工程。

scrapy startproject myscrapy

        执行上面的命令后,会在当前目录下创建一个myscrapy子目录。在myscrapy目录中还有一个myscrapy子目录,在该目录中有一堆子目录和文件,这些目录和文件就对应了图19-1所示的各部分。例如,spiders目录就对应了网络爬虫,其他的目录和文件先不用管。因为使用Scrapy框架编写网络爬虫的主要工作就是编写Spider。所有的Spider脚本文件都要放到spiders目录中。

        下面的例子会在spiders目录中建立一个firstSpider.py脚本文件,这是一个Spider程序,在该程序中会指定要抓取的Web资源的Url。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK