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(深圳) ...
随机推荐
- Postgres远程访问配置
在服务器上安装了Postgres数据库,然后通过客户端工具pgAdminIII来远程访问的过程中发现提醒服务器没有启动监听的错误.解决方法如下: 编辑Postgres安装路径下的/data/pg_hb ...
- More helpful Cocos2d and Gaming macros
More helpful Cocos2d and Gaming macros Here are w few macros that i wrote to make the code more read ...
- elasticsearch更新操作问题
elasticsearch在更新的时候,是通过id进行管理的,我们在前台传入id操作,id如果与elasticsearch相同,则覆盖,否则新增一条记录.且elasticsearch中的插入一条记录和 ...
- Mybatis Learning Notes 1
Mybatis Learning Notes 主要的参考是博客园竹山一叶的Blog,这里记录的是自己补充的内容 实体类属性名和数据库不一致的处理 如果是实体类的结果和真正的数据库的column的名称不 ...
- Asp.Net Core 入门(五)—— 布局视图_Layout.cshtml
布局视图和我们在Asp.Net MVC一样,布局视图_Layout.cshtml使得所有视图保持一致的外观变得更加容易,因为我们只有一个要修改的布局视图文件,更改后将立即反映在整个应用程序的所有视图中 ...
- 一、numpy入门
Array import numpy as np # create from python list list_1 = [1, 2, 3, 4] array_1 = np.array(list_1)# ...
- javascript单元测试框架mochajs详解(转载)
章节目录 关于单元测试的想法 mocha单元测试框架简介 安装mocha 一个简单的例子 mocha支持的断言模块 同步代码测试 异步代码测试 promise代码测试 不建议使用箭头函数 钩子函数 钩 ...
- orcal中创建和删除表空间和用户
1.创建表空间 create tablespace NW_DATA logging datafile 'F:\oracle\product\10.2.0\oradata\nwdb\NW_DATA.db ...
- What is the difference between try/except and assert?
assert only check if a condition is true or not and throw an exception. A try/except block can run a ...
- Bootstrap历练实例:带有下拉菜单的标签和胶囊导航
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...