scrapy框架之comand line tool
一 Global Command
1 startproject
https://docs.scrapy.org/en/latest/topics/commands.html#startproject
2 scrapy genspider -t basic baidu www.baidu.com
https://docs.scrapy.org/en/latest/topics/commands.html#genspider
3 settings
https://docs.scrapy.org/en/latest/topics/commands.html#settings
4 runspider
https://docs.scrapy.org/en/latest/topics/commands.html#runspider
5 shell
https://docs.scrapy.org/en/latest/topics/commands.html#shell
In []: response
Out[]: < https://www.baidu.com> In []: request
Out[]: <GET https://www.baidu.com> In []: view(response)
Out[]: True
6 fetch
https://docs.scrapy.org/en/latest/topics/commands.html#fetch
7view
https://docs.scrapy.org/en/latest/topics/commands.html#view
8 version
https://docs.scrapy.org/en/latest/topics/commands.html#version
二 Project-only Command
1 crawl
https://docs.scrapy.org/en/latest/topics/commands.html#crawl
2 check
https://docs.scrapy.org/en/latest/topics/commands.html#check
3 list
https://docs.scrapy.org/en/latest/topics/commands.html#list
4 edit(没啥用)
https://docs.scrapy.org/en/latest/topics/commands.html#edit
5 parse
https://docs.scrapy.org/en/latest/topics/commands.html#parse
6 bench
https://docs.scrapy.org/en/latest/topics/commands.html#bench
三 自定义命令
官方文档
https://docs.scrapy.org/en/latest/topics/commands.html#custom-project-commands
定义一个类,继承ScrapyCommand,实现run方法。
四 添加命令行参数
在命令行用crawl控制spider爬取的时候,加上-a选项,如
scrapy crawl WangyiSpider -a category=打车
然后在 spider 的构造函数里加上带入的参数:
import scrapy
class WangyiSpider(BaseSpider):
name = "Wangyi"
def __init__(self, category=None, *args, **kwargs):
super(WangyiSpider, self).__init__(*args, **kwargs)
scrapy框架之comand line tool的更多相关文章
- 安装scrapy框架的常见问题及其解决方法
下面小编讲一下自己在windows10安装及配置Scrapy中遇到的一些坑及其解决的方法,现在总结如下,希望对大家有所帮助. 常见问题一:pip版本需要升级 如果你的pip版本比较老,可能在安装的过程 ...
- 爬虫基础(五)-----scrapy框架简介
---------------------------------------------------摆脱穷人思维 <五> :拓展自己的视野,适当做一些眼前''无用''的事情,防止进入只关 ...
- python学习之-用scrapy框架来创建爬虫(spider)
scrapy简单说明 scrapy 为一个框架 框架和第三方库的区别: 库可以直接拿来就用, 框架是用来运行,自动帮助开发人员做很多的事,我们只需要填写逻辑就好 命令: 创建一个 项目 : cd 到需 ...
- 5、爬虫系列之scrapy框架
一 scrapy框架简介 1 介绍 (1) 什么是Scrapy? Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架,非常出名,非常强悍.所谓的框架就是一个已经被集成了各种功能(高性能 ...
- python 全栈开发,Day137(爬虫系列之第4章-scrapy框架)
一.scrapy框架简介 1. 介绍 Scrapy一个开源和协作的框架,其最初是为了页面抓取 (更确切来说, 网络抓取 )所设计的,使用它可以以快速.简单.可扩展的方式从网站中提取所需的数据.但目前S ...
- scrapy框架中Item Pipeline用法
scrapy框架中item pipeline用法 当Item 在Spider中被收集之后,就会被传递到Item Pipeline中进行处理 每个item pipeline组件是实现了简单的方法的pyt ...
- scrapy框架学习
一.初窥Scrapy Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架. 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中. 其最初是为了 页面抓取 (更确切来说, 网 ...
- python网络爬虫(1)——安装scrapy框架的常见问题及其解决方法
Scrapy是为了爬取网站数据而编写的一款应用框架,出名,强大.所谓的框架其实就是一个集成了相应的功能且具有很强通用性的项目模板. 其实在Linux和 Mac安装,就简单的pip命令即可: pip i ...
- scrapy框架综合运用 爬取天气预报 + 定时任务
爬取目标网站: http://www.weather.com.cn/ 具体区域天气地址: http://www.weather.com.cn/weather1d/101280601.shtm(深圳) ...
随机推荐
- POJ 3140 Contestants Division (树形DP,简单)
题意: 有n个城市,构成一棵树,每个城市有v个人,要求断开树上的一条边,使得两个连通分量中的人数之差最小.问差的绝对值.(注意本题的M是没有用的,因为所给的必定是一棵树,边数M必定是n-1) 思路: ...
- sourceTree配置bitbucket
1. 为github增加账号信息 选择添加远程库 选择添加一个账号 输入用户名: 按照提示输入密码 选择bitbuchet为默认 选中搜索克隆
- 如何解决源码安装软件中make时一直重复打印configure信息
在通过源码安装软件时,会出现执行./configure后再make时总是重复打印configure的信息,无法进入下一阶段的安装. 主要原因是系统当前的时间与实际时间不一致,特别是在虚拟机上经常会出现 ...
- tomcat假死现象 - 二
1 编写背景 最近服务器发现tomcat的应用会偶尔出现无法访问的情况.经过一段时间的观察最近又发现有台tomcat的应用出现了无法访问情况.简单描述下该台tomcat当时具体的表现:客户端请求没有响 ...
- Kernel Stack Overflow(转)
0x00 漏洞代码 stack_smashing.c #include <linux/init.h> #include <linux/module.h> #include &l ...
- js解析json格式
function save(){ var value2 = { "china":[ {"name":"hangzhou", "it ...
- Apache安装错误 APR not found解决方法
在配置Apache的时候,出现错误 原因是缺少一些依赖包,安装这些依赖包就行了 下载依赖包,注意我这里下载的与参考链接上的有些不同,安装上也有不一样 wget http://archive.apach ...
- 五分钟入门 Dingo API
基于 https://laravel-china.org/doc... 文档更简洁的描述Dingo,直戳重点,注重实践 Django-Book 概述 Dingo API帮助您轻松快速地构建自己的API ...
- Mining of Massive Datasets-1
given lots of data->discover patterns and models that are: valid, useful, unexpected, understanda ...
- (转))iOS App上架AppStore 会遇到的坑
iOS App上架AppStore 会遇到的坑 前言:非原创 文章摘自:http://zhuanlan.zhihu.com/100000PM/20010725 相信大家一定非常「深恶痛疾」AppS ...