scrapy常用命令

创建项目

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
 驱动器 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 字节
               3 个目录 149,355,196,416 可用字节

查看可用模板

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

创建爬虫文件

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
 驱动器 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 字节
               3 个目录 149,355,225,088 可用字节

 输出到json line格式,要求parse函数中使用yield返回字典数据

scrapy crawl spiderjob -o ../out/spiderjob.j

作者:tonyemail_st
链接:https://www.jianshu.com/p/6087fbcf3e99
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值