scrapy / scrapy

Scrapy, a fast high-level web crawling & scraping framework for Python.
https://scrapy.org
BSD 3-Clause "New" or "Revised" License
50.99k stars 10.34k forks source link

AttributeError: 'Decompressor' object has no attribute 'process' #6291

Closed phillipshaong closed 1 month ago

phillipshaong commented 1 month ago

Description

I am getting an error from running the demo example. AttributeError: 'Decompressor' object has no attribute 'process'. It. looks like it is an internal library to scrapy.

Steps to Reproduce

I am using the demo example from the website: https://scrapy.org/

Create the file: myspider.py

import scrapy

class BlogSpider(scrapy.Spider):
    name = 'blogspider'
    start_urls = ['https://www.zyte.com/blog/']

    def parse(self, response):
        for title in response.css('.oxy-post-title'):
            yield {'title': title.css('::text').get()}

        for next_page in response.css('a.next'):
            yield response.follow(next_page, self.parse)

Run scrapy runspider myspider.py

Expected behavior:

The website is scrapped.

Actual behavior:

(base) phillipng@pn web_scrapping % python -m scrapy runspider myspider.py
2024-03-13 14:53:45 [scrapy.utils.log] INFO: Scrapy 2.11.1 started (bot: scrapybot)
2024-03-13 14:53:45 [scrapy.utils.log] INFO: Versions: lxml 4.9.2.0, libxml2 2.9.13, cssselect 1.2.0, parsel 1.8.1, w3lib 2.1.2, Twisted 24.3.0, Python 3.10.10 (main, Mar 21 2023, 13:41:05) [Clang 14.0.6 ], pyOpenSSL 23.0.0 (OpenSSL 1.1.1t  7 Feb 2023), cryptography 39.0.1, Platform macOS-14.2.1-arm64-arm-64bit
2024-03-13 14:53:45 [scrapy.addons] INFO: Enabled addons:
[]
2024-03-13 14:53:45 [py.warnings] WARNING: /Volumes/sandisk/phillipng/Code/miniconda3/lib/python3.10/site-packages/scrapy/utils/request.py:254: ScrapyDeprecationWarning: '2.6' is a deprecated value for the 'REQUEST_FINGERPRINTER_IMPLEMENTATION' setting.

It is also the default value. In other words, it is normal to get this warning if you have not defined a value for the 'REQUEST_FINGERPRINTER_IMPLEMENTATION' setting. This is so for backward compatibility reasons, but it will change in a future version of Scrapy.

See the documentation of the 'REQUEST_FINGERPRINTER_IMPLEMENTATION' setting for information on how to handle this deprecation.
  return cls(crawler)

2024-03-13 14:53:45 [scrapy.utils.log] DEBUG: Using reactor: twisted.internet.selectreactor.SelectReactor
2024-03-13 14:53:45 [scrapy.extensions.telnet] INFO: Telnet Password: 636ba30c71014b15
2024-03-13 14:53:45 [scrapy.middleware] INFO: Enabled extensions:
['scrapy.extensions.corestats.CoreStats',
 'scrapy.extensions.telnet.TelnetConsole',
 'scrapy.extensions.memusage.MemoryUsage',
 'scrapy.extensions.logstats.LogStats']
2024-03-13 14:53:45 [scrapy.crawler] INFO: Overridden settings:
{'SPIDER_LOADER_WARN_ONLY': True}
2024-03-13 14:53:45 [scrapy.middleware] INFO: Enabled downloader middlewares:
['scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware',
 'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware',
 'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware',
 'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware',
 'scrapy.downloadermiddlewares.retry.RetryMiddleware',
 'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware',
 'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware',
 'scrapy.downloadermiddlewares.redirect.RedirectMiddleware',
 'scrapy.downloadermiddlewares.cookies.CookiesMiddleware',
 'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware',
 'scrapy.downloadermiddlewares.stats.DownloaderStats']
2024-03-13 14:53:45 [scrapy.middleware] INFO: Enabled spider middlewares:
['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware',
 'scrapy.spidermiddlewares.offsite.OffsiteMiddleware',
 'scrapy.spidermiddlewares.referer.RefererMiddleware',
 'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware',
 'scrapy.spidermiddlewares.depth.DepthMiddleware']
2024-03-13 14:53:45 [scrapy.middleware] INFO: Enabled item pipelines:
[]
2024-03-13 14:53:45 [scrapy.core.engine] INFO: Spider opened
2024-03-13 14:53:45 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2024-03-13 14:53:45 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023
2024-03-13 14:53:45 [scrapy.core.scraper] ERROR: Error downloading <GET https://www.zyte.com/blog/>
Traceback (most recent call last):
  File "/Volumes/sandisk/phillipng/Code/miniconda3/lib/python3.10/site-packages/twisted/internet/defer.py", line 2003, in _inlineCallbacks
    result = context.run(gen.send, result)
  File "/Volumes/sandisk/phillipng/Code/miniconda3/lib/python3.10/site-packages/scrapy/core/downloader/middleware.py", line 68, in process_response
    method(request=request, response=response, spider=spider)
  File "/Volumes/sandisk/phillipng/Code/miniconda3/lib/python3.10/site-packages/scrapy/downloadermiddlewares/httpcompression.py", line 90, in process_response
    decoded_body = self._decode(
  File "/Volumes/sandisk/phillipng/Code/miniconda3/lib/python3.10/site-packages/scrapy/downloadermiddlewares/httpcompression.py", line 134, in _decode
    return _unbrotli(body, max_size=max_size)
  File "/Volumes/sandisk/phillipng/Code/miniconda3/lib/python3.10/site-packages/scrapy/utils/_compression.py", line 64, in _unbrotli
    output_chunk = decompressor.process(input_chunk)
AttributeError: 'Decompressor' object has no attribute 'process'
2024-03-13 14:53:46 [scrapy.core.engine] INFO: Closing spider (finished)
2024-03-13 14:53:46 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 228,
 'downloader/request_count': 1,
 'downloader/request_method_count/GET': 1,
 'downloader/response_bytes': 71468,
 'downloader/response_count': 1,
 'downloader/response_status_count/200': 1,
 'elapsed_time_seconds': 0.322945,
 'finish_reason': 'finished',
 'finish_time': datetime.datetime(2024, 3, 13, 20, 53, 46, 33373, tzinfo=datetime.timezone.utc),
 'log_count/DEBUG': 1,
 'log_count/ERROR': 1,
 'log_count/INFO': 10,
 'log_count/WARNING': 1,
 'memusage/max': 60178432,
 'memusage/startup': 60178432,
 'scheduler/dequeued': 1,
 'scheduler/dequeued/memory': 1,
 'scheduler/enqueued': 1,
 'scheduler/enqueued/memory': 1,
 'start_time': datetime.datetime(2024, 3, 13, 20, 53, 45, 710428, tzinfo=datetime.timezone.utc)}
2024-03-13 14:53:46 [scrapy.core.engine] INFO: Spider closed (finished)

Reproduces how often: Everytime

Versions

(base) phillipng@pn web_scrapping % scrapy version --verbose Scrapy : 2.11.1 lxml : 4.9.2.0 libxml2 : 2.9.13 cssselect : 1.2.0 parsel : 1.8.1 w3lib : 2.1.2 Twisted : 24.3.0 Python : 3.10.10 (main, Mar 21 2023, 13:41:05) [Clang 14.0.6 ] pyOpenSSL : 23.0.0 (OpenSSL 1.1.1t 7 Feb 2023) cryptography : 39.0.1 Platform : macOS-14.2.1-arm64-arm-64bit

Additional context

None

Laerte commented 1 month ago

Duplicated: https://github.com/scrapy/scrapy/issues/6252#issuecomment-1968283966