#Windows平臺 一、pip3 install wheel 三、pip3 install lxml 四、pip3 install pyopenssl 五、pip3 install pywin32 #若是不行去官網https://sourceforge.net/projects/pywin32/files/pywin32/ 六、pip3 install twisted #若是不行去官網:http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted 七、pip3 install scrapy #Linux平臺 一、pip3 install scrapy
#1 查看幫助 scrapy -h scrapy <command> -h #2 有兩種命令:其中Project-only必須切到項目文件夾下才能執行,而Global的命令則不須要 Global commands: startproject #建立項目 genspider #基本上都要cd項目目錄,scrapy genspider 名稱 url settings #若是是在項目目錄下,則獲得的是該項目的配置 runspider #運行一個獨立的python文件,沒必要建立項目 shell #scrapy shell url地址 在交互式調試,如選擇器規則正確與否 fetch #獨立於程單純地爬取一個頁面,能夠拿到請求頭 view #下載完畢後直接彈出瀏覽器,以此能夠分辨出哪些數據是ajax請求 version #scrapy version 查看scrapy的版本,scrapy version -v查看scrapy依賴庫的版本 Project-only commands: crawl #運行爬蟲,必須建立項目才行,確保配置文件中ROBOTSTXT_OBEY = False check #檢測項目中有無語法錯誤 list #列出項目中所包含的爬蟲名 edit #編輯器,通常不用 parse #scrapy parse url地址 --callback 回調函數 #以此能夠驗證咱們的回調函數是否正確 bench #scrapy bentch壓力測試 #3 官網連接 https://docs.scrapy.org/en/latest/topics/commands.html
crawl
運行爬蟲程序若是不打印日誌html
scrapy crawl 爬蟲程序中的name --nolog
python