Scrapy command line tool
来源:互联网 发布:h5小游戏源码下载 编辑:程序博客网 时间:2024/05/16 09:09
本文记录scrapy command中常用命令,所有命令来自scrapy官方文档
创建项目(creating projects)
scrapy startproject myproject[project_dir]
将会创建一个scrapy项目在project_dir目录下,如果project_dir没有写出,则汇创建一个与项目同名的文件夹
之后进入新项目目录
cd project_dir
创建spider scrapy genspider mydomain mydomain.com
scrapy genspider mydomain mydomain.comscrapy genspider -t crawl scrapyorg scrapy.org
查看所有可用命令
scrapy -h
crawl
项目内命令
scrapy crawl <spider>
list
项目内命令
scrapy list
fetch
不需要在项目内
按照scrapy downloader的方式下载url内容
如果在项目外运行,按照默认的scrpy downloader设置下载
支持的选项
–spider = SPIDER:使用特定spider
–headers:打印response头代替response内容
–no-redirect:不进行重定向请求
scrapy fetch --nolog http://www.example.com/some/page.htmlscrapy fetch --nolog --headers http://www.example.com/
view
不需要在项目内
可选命令
在浏览器中打开给定的URL,并以Scrapy spider获取到的形式展现。 有些时候spider获取到的页面和普通用户看到的并不相同。 因此该命令可以用来检查spider所获取到的页面,并确认这是您所期望的。
–spider=Spider:使用特定spider
–no-redirect:不进行重定向请求
scrapy view http://www.example.com/some/page.html
shell
scrapy shell [url]
获取更多信息
scrapy shell http://www.example.com/some/page.htmlscrapy shell --nolog http://www.example.com/ -c '(response.status,response.url)'# you can disable this with --no-redirect# (only for the URL passed as command line argument)scrapy shell --no-redirect --nolog http://httpbin.org/redirect-to?url=http%3A%2F%2Fexample.com%2F -c '(response.status, response.url)'
parse
语法:scrapy parse <url> [options]
是否需要项目: yes
获取给定的URL并使用相应的spider分析处理。如果您提供 –callback 选项,则使用spider的该方法处理,否则使用 parse 。
支持的选项:
–spider=SPIDER: 跳过自动检测spider并强制使用特定的spider
–a NAME=VALUE: 设置spider的参数(可能被重复)
–callback or -c: spider中用于解析返回(response)的回调函数
–pipelines: 在pipeline中处理item
–rules or -r: 使用 CrawlSpider 规则来发现用来解析返回(response)的回调函数
–noitems: 不显示爬取到的item
–nolinks: 不显示提取到的链接
–nocolour: 避免使用pygments对输出着色
–depth or -d: 指定跟进链接请求的层次数(默认: 1)
–verbose or -v: 显示每个请求的详细信息
$ scrapy parse http://www.example.com/ -c parse_item[ ... scrapy log lines crawling example.com spider ... ]>>> STATUS DEPTH LEVEL 1 <<<# Scraped Items ------------------------------------------------------------[{'name': u'Example item', 'category': u'Furniture', 'length': u'12 cm'}]# Requests -----------------------------------------------------------------[]
- Scrapy command line tool
- Scrapy学习笔记III-Command line tool
- Scrapy学习笔记(3)--Command line tool(命令行工具)
- xcode command line tool
- 使用Java Command Line Tool开发应用程序
- UV Atlas Command-Line Tool (uvatlas.exe)
- Using the 'nasl' Nessus Command Line Tool
- MAC Yosemite安装Xcode Command Line Tool
- 在Mac安装cmake command line tool
- 【小结】利用zf Command Line Tool 建立项目结构
- Could not generate command line for the ‘VCCLCompilerTool’ tool
- Mac OS app, sandbox with command line tool
- Mac OS app, sandbox with command line tool?
- How to Use Android ADB Command Line Tool on mac
- macos安装xcode command line tool的两种方法
- command line
- command line
- command line
- numpy中linspace用法
- 新增的元素和废除的元素、新增的属性和废除的属性
- androidx86 换4.9kernel 踩坑
- xpath解析网页中tbody问题
- LeetCode 25. Reverse Nodes in k-Group
- Scrapy command line tool
- 2017年7月25日---阶段性工作总结
- 【Zookeeper】——Why should we use zookeeper?
- System类
- 数论之乘法逆元
- TCP socket 非阻塞
- DiskLruCache知识点
- webview的使用
- HTML CSS简单了解笔记