一种基于请求html的web爬虫,主要针对url验证测试。

requests-crawler的Python项目详细描述


请求爬网程序

一种基于requests-html的网络爬虫,主要针对url验证测试。

功能

  • 基于requests-html完整的javascript支持!
  • 支持请求频率限制,例如RPS/RPM
  • 支持带有标题和cookies的爬网
  • 包含和排除机制
  • 按http状态代码对访问过的url进行分组
  • 显示URL的引用和超链接

安装/升级

$ pip install requests-crawler

仅支持python 3.6

为了确保安装或升级成功,可以执行命令requests_crawler -V,查看是否可以获得正确的版本号。

$ requests_crawler -V
0.5.3

用法

$ requests_crawler -h
usage: requests_crawler [-h] [-V] [--log-level LOG_LEVEL]
                        [--seed SEED]
                        [--headers [HEADERS [HEADERS ...]]]
                        [--cookies [COOKIES [COOKIES ...]]]
                        [--requests-limit REQUESTS_LIMIT]
                        [--interval-limit INTERVAL_LIMIT]
                        [--include [INCLUDE [INCLUDE ...]]]
                        [--exclude [EXCLUDE [EXCLUDE ...]]]
                        [--workers WORKERS]

A web crawler based on requests-html, mainly targets for url validation test.

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show version
  --log-level LOG_LEVEL
                        Specify logging level, default is INFO.
  --seed SEED           Specify crawl seed url
  --headers [HEADERS [HEADERS ...]]
                        Specify headers, e.g. 'User-Agent:iOS/10.3'
  --cookies [COOKIES [COOKIES ...]]
                        Specify cookies, e.g. 'lang=en country:us'
  --requests-limit REQUESTS_LIMIT
                        Specify requests limit for crawler, default rps.
  --interval-limit INTERVAL_LIMIT
                        Specify limit interval, default 1 second.
  --include [INCLUDE [INCLUDE ...]]
                        Urls include the snippets will be crawled recursively.
  --exclude [EXCLUDE [EXCLUDE ...]]
                        Urls include the snippets will be skipped.
  --workers WORKERS     Specify concurrent workers number.

示例

基本用法。

$ requests_crawler --seed http://debugtalk.com

抓取标题和饼干。

$ requests_crawler --seed http://debugtalk.com --headers User-Agent:iOS/10.3 --cookies lang:en country:us

以30转/秒的速度爬行。

$ requests_crawler --seed http://debugtalk.com --requests-limit 30

爬行速度限制为500转/分。

$ requests_crawler --seed http://debugtalk.com --requests-limit 500 --interval-limit 60

使用额外主机进行爬网,例如httprunner.org也将递归爬网。

$ requests_crawler --seed http://debugtalk.com --include httprunner.org

跳过排除的url片段,例如url includehttprunner将被跳过。

$ requests_crawler --seed http://debugtalk.com --exclude httprunner

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java无法从spring resttemplate访问sms网关   使用spark上下文方法参数的java并行化集合不正确   java中ReadLock的并发检查副本   java基于属性比较两个列表是否具有相同的元素   字符串Java文本块:缩进前缀中的制表符和空格的混合   java如何将带有@SpringBootApplication的maven模块作为测试范围中的依赖项添加到另一个maven模块   我需要一些关于在Java中使用2个jar文件的帮助   mysql JPA Java Spring Boot执行查找/连接表   java对话框选择具有特定名称的文件   java如何修复Spring工具套件4中的端口8080错误?   Java中的apache poi Excel阅读器   java如何在tomcat访问日志中记录线程上下文值   java有一种方法可以创建类<T>的实例,该类将类作为传递泛型的构造函数中的参数   默认情况下,java GORM onetomany映射执行即时抓取   java不能在安卓中接受全局变量   统计系统的java MongoDB异步驱动程序排名   java如何解析:无法解析插件“org.springframework.ide.eclipse.ui”?   用Java从一副牌中随机抽取5张牌   javaapachecamel动态消费者   java如何克服使用Flood Fill 4算法时的“薄边界”问题?