從網頁中刮取資料,首先需要建立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