scrapy 6023 telnet查看爬虫引擎相关状态

news/2024/7/19 9:11:44 标签: python, 爬虫

Telnet终端(Telnet Console)

Scrapy提供了内置的telnet终端,以供检查,控制Scrapy运行的进程。 telnet仅仅是一个运行在Scrapy进程中的普通python终端。因此您可以在其中做任何事。

telnet终端是一个 自带的Scrapy扩展 。 该扩展默认为启用,不过您也可以关闭。 关于扩展的更多内容请参考 Telnet console 扩展

如何访问telnet终端

telnet终端监听设置中定义的 TELNETCONSOLE_PORT ,默认为 6023 。 访问telnet请输入:

telnet localhost 6023
>>>

Windows及大多数Linux发行版都自带了所需的telnet程序。

telnet终端中可用的变量

telnet仅仅是一个运行在Scrapy进程中的普通python终端。因此您可以做任何事情,甚至是导入新终端。

telnet为了方便提供了一些默认定义的变量:

快捷名称描述
crawlerScrapy Crawler (scrapy.crawler.Crawler 对象)
engineCrawler.engine属性
spider当前激活的爬虫(spider)
slotthe engine slot
extensions扩展管理器(manager) (Crawler.extensions属性)
stats状态收集器 (Crawler.stats属性)
settingsScrapy设置(setting)对象 (Crawler.settings属性)
est打印引擎状态的报告
prefs针对内存调试 (参考 调试内存溢出)
ppprint.pprint 函数的简写
hpy针对内存调试 (参考 调试内存溢出)

Telnet console usage examples

下面是使用telnet终端的一些例子:

查看引擎状态

在终端中您可以使用Scrapy引擎的 est() 方法来快速查看状态:

telnet localhost 6023
>>> est()
Execution engine status

time()-engine.start_time                        : 8.62972998619
engine.has_capacity()                           : False
len(engine.downloader.active)                   : 16
engine.scraper.is_idle()                        : False
engine.spider.name                              : followall
engine.spider_is_idle(engine.spider)            : False
engine.slot.closing                             : False
len(engine.slot.inprogress)                     : 16
len(engine.slot.scheduler.dqs or [])            : 0
len(engine.slot.scheduler.mqs)                  : 92
len(engine.scraper.slot.queue)                  : 0
len(engine.scraper.slot.active)                 : 0
engine.scraper.slot.active_size                 : 0
engine.scraper.slot.itemproc_size               : 0
engine.scraper.slot.needs_backout()             : False

暂停,恢复和停止Scrapy引擎

暂停:

telnet localhost 6023
>>> engine.pause()
>>>

恢复:

telnet localhost 6023
>>> engine.unpause()
>>>

停止:

telnet localhost 6023
>>> engine.stop()
Connection closed by foreign host.

Telnet终端信号

scrapy.telnet. update_telnet_vars (telnet_vars)

在telnet终端开启前发送该信号。您可以挂载(hook up)该信号来添加,移除或更新 telnet本地命名空间可用的变量。 您可以通过在您的处理函数(handler)中更新 telnet_vars 字典来实现该修改。

参数:telnet_vars (dict) – telnet变量的字典

Telnet设定

以下是终端的一些设定:

TELNETCONSOLE_PORT

Default: [6023, 6073]

telnet终端使用的端口范围。如果设为 None0 , 则动态分配端口。

TELNETCONSOLE_HOST

默认: '127.0.0.1'

telnet终端监听的接口(interface)。


http://www.niftyadmin.cn/n/1121046.html

相关文章

Linux将yum源设置为阿里云的镜像源

第一步:备份原有镜像源 mv /etc/yum.repo.d/Centos-Base.repo /etc/yum.repo.d/Centos-Base.repo.bak 第二步:下载阿里云的镜像源 wget -O /etc/yum.repo.d/Centos-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo //如果是cento 5的系统就将文…

nopCommerce的配置以及汉化

这里给大家一些链接,是关于nopCommerce的一些介绍: nopCommerce的源代码 关于nopcommerce Nopcommerce中文资源 第一步 配置nopCommerce 先上一张图,nopCommerce的简单结构,nopCommerce架构分析系列有详细的介绍! 注意 : 运行之前 需要把Nop.Web 设为启动项,如图: 然后直接运…

OCP-1Z0-051 第135题 子查询注意事项

一、原题 Which three statements are true regarding subqueries? (Choose three.) A. Subqueries can contain GROUP BY and ORDER BY clauses. B. Main query and subquery can get data from different tables. C. Main query and subquery must get data from the same …

简单文件输入输出

写入到文本文件&#xff1a; // outfile.cpp -- writing to a file #include <iostream> #include <fstream> // for file I/Oint main() {using namespace std;char automobile[50];int year;double a_price;double d_price;ofstream outFile; …

1年生の仕上げはやはり試合-SOCCER

時間項目プレ フリードリブル挨拶  【パート1】30分大人がリードして正しい動きを体感させる。ウォームアップ8分軽く足踏み  1,2,3で膝を前に上げる(左右交互)いずれか4項目 1,2,3で足を前に上げる(左右交互)それぞれ2分ずつ 1,2,3で足を横に上げる(左右交互)必ず大きな…

将pdf格式的文件转换成图片

1 public class PdfToImage {2 3 private static String UPLOAD_DIR "upload" File.separator;4 5 /**6 * 获取上传的文件7 * param uploadPath8 * param file9 * return10 */11 private static File getUploadCalendarF…

函数原型中int *arr和int arr[]

截图来自&#xff1a;C Primer Plus(第6版) 中文版

OCP-1Z0-051 第136题 子查询的使用

一、原题 View the Exhibit and examine the structure of the PRODUCTS table. Which two tasks would require subqueries? (Choose two.) A. Display the minimum list price for each product status. B. Display all suppliers whose list price is less than 1000. C.…