天天看點

scrapy常用指令筆記

1、scrapy --help     

檢視scrapy的基本指令

2、scrapy version -v  檢視scrapy版本和各元件的資訊

3、scrapy startproject xx 

建立一個xx工程

4、scrapy genspider name site.com    要進入工程目錄下 name為檔案名;site.com為要爬取的網站的域名 有兩種情況:1、在工程中産生一個spider                      2、在同一個工程産生多個spider,不同的spider要求name不同

scrapy genspider -l     檢視爬蟲模闆

5、scrapy list  檢視工程中所有的spider file

6、scrapy view url 檢視頁面源碼在浏覽器中顯示的樣子

7、scrapy parse url 在工程中使用固定的parse函數解析某個頁面

8、scrapy shell url(html)

eg:  scrapy shell https://doc.scrapy.org/en/latest/_static/selectors-sample1.html 用于調試資料、檢測xpath、檢視頁面源碼等等

9、scrapy runspider xx.py     運作單個爬蟲

  scrapy crawl name     運作工程裡的爬蟲

eg: scrapy crawl douban_movie_top250 -o douban.csv

10、scrapy bench 執行一個基準測試。可以用來檢測scrapy是否安裝成功