Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SplashRequest gives - TypeError: attrs() got an unexpected keyword argument 'eq'

I am using a cloud Splash instance from ScrapingHub. I am trying to do a simple request using the Scrapy-Splash library and I keep getting the error:

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

Any ideas/clues about why the error is showing up would be much appreciated.

The code I'm using looks like this (using Python 3.6 and 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()

and settings.py has the following values:

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'
like image 999
Ankur Avatar asked May 20 '20 03:05

Ankur


People also ask

Is ATTRS an argument to the field in the widget?

Bookmark this question. Show activity on this post. What i did wrong. Show activity on this post. attrs is not an argument to the field, it's an argument to the widget. Note that some browsers don't allow styling of the file input. Show activity on this post.

Is it possible to update ATTRS in dephell's environment?

So, update attrs in the dephell's environment, and everything will be ok I understand it's not backwards compatible, I just want the version constraint updated so that pip correctly pulls in attrs>=19.2.

Why is ATTRS not working on my Machine?

You have an old / unsupported version of attrs installed on your machine. You can remove it with pip3 uninstall attrs or pip uninstall attrs. Sorry, something went wrong.


2 Answers

The error is coming from the Twisted library, which is a dependency of Scrapy.

It looks like it's fixed in the latest version. If you run

pip install --upgrade twisted

you should be fine!

like image 126
Ryan Specht Avatar answered Oct 16 '22 22:10

Ryan Specht


I also had to upgrade attrs in order to make the error message disappear.

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

I found this on: https://www.programmersought.com/article/61587312947

like image 38
Irina S. Avatar answered Oct 16 '22 22:10

Irina S.