scrapy常用命令

創(chuàng)建項目

D:\tmp\scrapy>scrapy startproject testproject
New Scrapy project 'testproject', using template directory 'c:\\users\\tony\\app
data\\local\\programs\\python\\python35\\lib\\site-packages\\scrapy\\templates\\
project', created in:
    D:\tmp\scrapy\testproject

You can start your first spider with:
    cd testproject
    scrapy genspider example example.com

D:\tmp\scrapy>dir
 驅(qū)動器 D 中的卷沒有標簽。
 卷的序列號是 C5EE-F557

 D:\tmp\scrapy 的目錄

2017/10/23  19:53    <DIR>          .
2017/10/23  19:53    <DIR>          ..
2017/10/23  19:53    <DIR>          testproject
               0 個文件              0 字節(jié)
               3 個目錄 149,355,196,416 可用字節(jié)

查看可用模板

D:\tmp\scrapy\tet>scrapy genspider -l
Available templates:
  basic
  crawl
  csvfeed
  xmlfeed

創(chuàng)建爬蟲文件

D:\tmp\scrapy\tet>scrapy genspider -t basic spidername http://www.jsit.edu.cn
Created spider 'spidername' using template 'basic' in module:
  tet.spiders.spidername

D:\tmp\scrapy\tet\tet>dir spiders
 驅(qū)動器 D 中的卷沒有標簽。
 卷的序列號是 C5EE-F557

 D:\tmp\scrapy\tet\tet\spiders 的目錄

2017/10/23  19:49    <DIR>          .
2017/10/23  19:49    <DIR>          ..
2017/10/23  19:49               249 spidername.py
2017/10/23  19:42               237 test.py
2017/10/23  19:40               588 tset2.py
2017/10/23  19:41               588 tset3.py
2017/10/23  15:33               161 __init__.py
2017/10/23  19:44    <DIR>          __pycache__
               5 個文件          1,823 字節(jié)
               3 個目錄 149,355,225,088 可用字節(jié)

輸出到json line格式,要求parse函數(shù)中使用yield返回字典數(shù)據(jù)

scrapy crawl spiderjob -o ../out/spiderjob.j
最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容