ScrapydWeb安装步骤:

  ScrapydWeb:用于 Scrapyd 集群管理的web应用,支持 Scrapy 日志分析和可视化。
官方文档:https://github.com/my8100/files/blob/master/scrapydweb/README_CN.md

一、安装Scrapyd

ScrapydWeb是基于Scrapyd的一个Web应用,所以要先安装并启动Scrapyd.
命令:

pip install scrapyd

安装完成后,cmd模式下输入scrapyd启动

如需远程访问scrapyd,需做如下修改:

  • 找到Python库下的Scrapyd文件夹,如我的地址为:D:\Python\Python36\Lib\site-packages\scrapyd
  • 打开文件“default_scrapyd.conf”,修改bind_address,默认为127.0.0.1
  • 重启scrapyd服务

测试是否启动成功,访问http://127.0.0.1:6800/,并出现如下相应即安装成功
在这里插入图片描述

2.安装ScrapydWeb

命令:

pip install scrapydweb

在保持scrapyd挂起的情况下运行命令scrapydweb,也就是需要打开两个doc窗口.

3.配置ScrapydWeb配置文件

①.运行命令scrapydweb,首次启动将会在当前目录下生成配置文件“scrapydweb_settings_v8.py”
②.更改配置文件
编辑配置文件,将ENABLE_LOGPARSER更改为False

ENABLE_LOGPARSER = False

如未更改,将会报如下错误:

ERROR in scrapydweb.run: Check app config fail:

In order to automatically run LogParser at startup, you have to set up the SCRAPYD_LOGS_DIR option first.
Otherwise, set 'ENABLE_LOGPARSER = False' if you are not running any Scrapyd service on the current ScrapydWeb host.
Note that you can run the LogParser service separately via command 'logparser' as you like.
Check and update your settings in C:/Users/hunk/scrapydweb_settings_v8.py

③.添加访问权限
如果需要冲外部访问,添加SCRAPYD_SERVERS,支持字符串和元组两种配置格式,支持添加认证信息和分组标签:

SCRAPYD_SERVERS = [
    '127.0.0.1:6800',
    # 'username:password@localhost:6801#group',
    ('username', 'password', 'localhost', '6801', 'group'),
]

并启动HTTP基本认证:

ENABLE_AUTH = True
USERNAME = 'username'
PASSWORD = 'password' 

重新运行命令scrapydweb,启动,访问http://127.0.0.1:5000,并出现如下页面即成功运行:
在这里插入图片描述

错误及解决方法:

Fatal error in launcher: Unable to create process using '"' 

原因:我出现这个原因是因为电脑中同时存在Python2和Python3环境,并将Python.exe改为Python3.exe,导致调用冲突

解决方法:将暂时不用的Python版本的环境变量删掉后,将Python3.exe改为Python.exe。如若依旧出现这种情况,卸载包后重新安装 .

builtins.AttributeError: 'int' object has no attribute 'splitlines'

原因:scrapyd需要指定版本Scrapy为1.6.0,Twisted为18.9.0
解决方法:回退版本
命令:

pip install Scrapy==1.6.0
pip install Twisted==18.9.0

在回退版本中,如果出现需要
error: Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”: http://landinghub.visualstudio.com/visual-cpp-build-tools
的错误,则需要安装c环境:
下载链接:https://download.microsoft.com/download/5/f/7/5f7acaeb-8363-451f-9425-68a90f98b238/visualcppbuildtools_full.exe?fixForIE=.exe.
默认安装,重新pip即可。

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐