SplashRequest 给出 - TypeError: attrs() 得到一个意外的关键字参数'eq'



我正在使用来自ScrapingHub的云Splash实例。我正在尝试使用 Scrapy-Splash 库执行一个简单的请求,但不断收到错误:

@attr.s(hash=False, repr=False, eq=False)
TypeError: attrs() got an unexpected keyword argument 'eq'

有关错误出现原因的任何想法/线索将不胜感激。

我使用的代码看起来像这样(使用 Python 3.6 和 Scrapy v 2.1.0(:

import scrapy
from scrapy_splash import SplashRequest

class MySpider(scrapy.Spider):
start_urls = ['https://www.sportsgirl.com.au', 'http://maryons.com.au']
def start_requests(self):
for url in self.start_urls:
yield SplashRequest(url, self.parse, args={'wait': 0.5})
def parse(self, response):    
print(response)

MySpider().start_requests()

settings.py 具有以下值:

DOWNLOADER_MIDDLEWARES = {
'scrapy_splash.SplashCookiesMiddleware': 723,
'scrapy_splash.SplashMiddleware': 725,
'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware': 810,
}
SPIDER_MIDDLEWARES = {
'scrapy_splash.SplashDeduplicateArgsMiddleware': 100,
}
SPLASH_URL = 'https://my-splash-url.scrapinghub.com'

错误来自 Twisted 库,它是 Scrapy 的依赖项。

看起来它在最新版本中已修复。如果您运行

pip install --upgrade twisted

你应该没事!

我还必须升级 attrs 以使错误消息消失。

pip3 install attrs==19.2.0 -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com

我在以下位置找到了这个:https://www.programmersought.com/article/61587312947

相关内容

最新更新