Release notes

Scrapy 2.20.0 (2026-11-06)

Highlights:

  • Web-browser-like detection of response encodings, base URLs and meta refresh redirects, powered by frostwork

  • Requests can be awaited to get their response

  • Non-asyncio Twisted reactors are deprecated

Security bug fixes

  • Scrapy now limits by default the memory that responses can take, fixing CVE-2017-14158.

    In previous Scrapy versions, the only limit on the total size of responses in memory, SCRAPER_SLOT_MAX_ACTIVE_SIZE, covered responses waiting for or going through spider callbacks. Responses to other requests, like those of media pipelines, had no limit. For example, when media pipelines downloaded files faster than they could store them, e.g. to Amazon S3, the downloaded files piled up in memory, so a crawled website could make Scrapy run out of memory.

    The new RESPONSE_MAX_ACTIVE_SIZE setting replaces SCRAPER_SLOT_MAX_ACTIVE_SIZE and covers all responses in memory, including those to awaited requests and to requests sent with ExecutionEngine.download_async(). Use it to change or disable the limit. The shell disables it.

    (#482, #4583, #6430, #8417, #8459, #8460)

  • HttpCompressionMiddleware now decodes at most 1 content coding per response by default, and drops responses that apply more with IgnoreRequest.

    In previous Scrapy versions, the number of content codings was unlimited, so a malicious server could send a response with a Content-Encoding header that chains thousands of codings (e.g. gzip, gzip, gzip, …) to make Scrapy run as many decompression passes, causing high CPU and memory usage. See the j72p-v7rm-cwm3 security advisory for details.

    To allow more content codings per response, set the new COMPRESSION_MAX_ENCODINGS setting.

  • When http_auth_domain is not set, the credentials from http_user and http_pass are now only sent to the origin (scheme, host and port) of the request where they were first used.

    In previous Scrapy versions, they were sent to any URL, so after a cross-origin redirect, HttpAuthMiddleware added them again to the Authorization header that RedirectMiddleware had removed, sending them to the redirect target. A website could redirect Scrapy to a host under its control to steal those credentials. See the 466x-p45j-m4fx security advisory for details.

    (#8329)

  • When using a proxy from the http_proxy or https_proxy environment variables, redirects now honor the no_proxy environment variable.

    In previous Scrapy versions, a redirect to a URL with the same scheme kept the proxy of the original request, even if the redirect host matched no_proxy. A website could redirect Scrapy to an internal host, and that request would be sent through the proxy. For http:// URLs, this exposed the request to the proxy, including any cookies or credentials for that host, and allowed the proxy to forge the response. See the x3px-j3qh-fp5w security advisory for details.

  • S3FilesStore now uses HTTPS with the default Scrapy settings.

    In previous Scrapy versions, the default value of AWS_USE_SSL, None, was incorrectly interpreted to mean “disable HTTPS”, so S3FilesStore used plain HTTP when talking to S3 unless that setting was explicitly set to True or AWS_ENDPOINT_URL was set to a custom HTTPS URL.

    An attacker who could observe that traffic could read the contents, S3 paths and metadata of the files uploaded by FilesPipeline and ImagesPipeline, the AWS access key ID (but not the secret access key) and, with temporary credentials, the session token (X-Amz-Security-Token). An attacker who could tamper with that traffic could make Scrapy falsely think that a file is up to date or was successfully stored. See the fwm7-29m4-rrj9 security advisory for details.

    To restore the previous behavior, set AWS_USE_SSL to False.

  • LxmlLinkExtractor and SitemapSpider now only follow http:// and https:// URLs by default, plus URLs that use the scheme of the response they come from.

    In previous Scrapy versions, link extractors also followed file:// and ftp:// URLs, and SitemapSpider followed URLs of any scheme. A crawled website could use that to make Scrapy read local files, send the FTP_USER and FTP_PASSWORD credentials to an FTP server of its choosing, or send requests signed with the AWS_ACCESS_KEY_ID credentials to an S3 bucket of its choosing. See the q7wc-mr9r-gcjh security advisory for details.

    To follow URLs with other schemes, use the new schemes parameter of LxmlLinkExtractor or the new sitemap_schemes attribute of SitemapSpider.

Modified requirements

Backward-incompatible changes

  • Changes to the fetch() shortcut of the Scrapy shell:

    • Requests are now downloaded with ExecutionEngine.download_async() instead of being passed to the scheduler. As a result, spider middlewares and duplicate filtering are no longer applied to them.

    • When a Request object is passed, its callback and errback are no longer called, and a warning is issued if they are set.

    • The engine is no longer started, so the engine_started and engine_stopped signals are not sent, and components that start on them, such as the MemoryUsage extension and the telnet console, do not run in the shell.

    (#8174, #8176, #8179)

  • Changes to the behavior of ExecutionEngine methods that change its state:

    • close_spider_async() now also stops the engine. Calling it while the spider is opening now closes the spider as soon as it is open, calling it while the spider is closing now completes immediately instead of waiting for the in-flight requests, and calling it after the spider has been closed no longer raises RuntimeError.

    • stop_async() now just calls close_spider_async() with the shutdown reason. Calling it after open_spider_async() and before start_async() now closes the spider instead of raising RuntimeError. Calling it while the spider is closing or after the engine has stopped now completes immediately, instead of raising RuntimeError or waiting for the in-flight requests.

    • start_async() now raises RuntimeError if called before open_spider_async() has finished, instead of sending the engine_started signal anyway, and if called after the engine has stopped.

    • The engine_stopped signal is now sent only after all engine_started handlers have finished.

    • If the spider is closed before the engine is started, for example by calling close_spider_async() from a spider_opened handler, the engine_started and engine_stopped signals are not sent.

    • Crawler.stop_async(), when called before the engine is running, e.g. while the spider is being opened, now closes the spider as soon as it is open, instead of being ignored.

    • A CloseSpider exception raised while the spider is opening now closes the spider as soon as it is open, instead of being re-raised by open_spider_async().

    • crawl() and download_async() now raise RuntimeError when called while the spider is closing, once the close has stopped waiting for the requests in progress.

    (#6916, #8217, #8272, #8319)

  • Setting the ExecutionEngine.running attribute no longer has any effect, and is deprecated. Its value is now False while the spider is closing. (#8181)

  • FTPDownloadHandler now enforces DOWNLOAD_MAXSIZE and DOWNLOAD_WARNSIZE, also when using ftp_local_filename, so downloads bigger than 1 GiB now fail by default. To download bigger files, raise the limit to a size that fits them, with DOWNLOAD_MAXSIZE or with the download_maxsize request meta key for specific requests. You can also set the limit to 0 to lift it altogether. (#8213)

  • The built-in HTTP download handlers now limit their open connections with the new CONCURRENT_CONNECTIONS_PER_HANDLER setting, whose default value is derived from the limit of open files of the process, or is 480 on Windows. HTTP11DownloadHandler and H2DownloadHandler had no such limit before, and AiohttpDownloadHandler and HttpxDownloadHandler used CONCURRENT_REQUESTS as their limit. If you set CONCURRENT_REQUESTS higher than that default, a warning is logged, and you need to set CONCURRENT_CONNECTIONS_PER_HANDLER or, on platforms other than Windows, raise the limit of open files of the process (see I get too many file descriptors in select() or Too many open files). (#2653, #5024, #5618, #7932)

  • HttpxDownloadHandler no longer falls back to the httpx package when httpx2 is not installed. Install the httpx extra to use it. (#7932)

  • Responses that your code keeps in memory, e.g. in the Request.meta of scheduled requests or in component attributes, now count toward RESPONSE_MAX_ACTIVE_SIZE until they are released, and so do responses in a reference cycle until Python’s garbage collector frees them. Keeping many responses can now slow down your crawl. To find out whether your crawl keeps responses alive, see Debugging memory leaks.

    If requests have been held back by the limit for 5 seconds with none being downloaded and no response released, Scrapy runs Python’s garbage collector and, if that releases no response, lets one request through, logging a warning the first time and increasing the new response_max_active_size/bypass_count stat.

    Scrapy itself no longer keeps responses alive in reference cycles after a request fails, e.g. with an HttpError that no errback handles, or after a failed media pipeline download.

    (#6430, #8417, #8459, #8460)

  • Header names in Headers objects, i.e. in Request.headers and Response.headers, now keep the case they are first set with, instead of being converted to Title-Case. Lookups are still case-insensitive, but code that iterates over header names and compares them to Title-Case strings must be updated.

    Over HTTP/1.1, AiohttpDownloadHandler and HttpxDownloadHandler now send header names in the case you write them in, and keep the case of response header names as received. See the comparison of download handlers.

    (#2711, #7893, #8265)

  • get_retry_request(), and hence RetryMiddleware, now sets the new skip_dupefilter_once request meta key on retry requests instead of setting their dont_filter attribute to True. As a result, with schedulers that support that meta key, like the default one, requests derived from a retry request, e.g. redirects, are no longer exempt from duplicate filtering. (#6895, #8224)

  • Requests whose meta is copied from a downloaded request, e.g. redirects and retries, are now assigned to the download slot of their own URL domain, instead of keeping the slot of the original request. Requests whose meta is copied from a request whose download_slot request meta key you set keep that slot, so set it to keep redirects and retries in the slot of the original request. (#8337)

  • http_user and http_pass are now only sent to the origin (scheme, host and port) of the request that you set them on, so they are no longer sent after a cross-origin redirect. To send them to a different origin, set the http_auth_domain request meta key. HttpAuthMiddleware also no longer sets the Authorization header of requests whose URL scheme is neither http nor https. (#8329)

  • Keys of component priority dictionaries, such as DOWNLOADER_MIDDLEWARES, that cannot be resolved into a component, e.g. the import path of a component that no longer exists, now raise ValueError, even if their priority is None. Some of them used to be silently ignored, and a missing module used to raise ModuleNotFoundError instead. Fix the import path or remove the entry. (#7820, #8159)

  • HttpCompressionMiddleware now raises DecompressionError for a response body that cannot be decompressed, instead of the exception of the underlying decompression library, e.g. zlib.error, OSError or EOFError. Update any code that catches those exceptions, e.g. in request errbacks. (#8177)

  • str() of a Spider object now returns its name. Use repr() to get the previous output, e.g. <MySpider 'my_spider' at 0x7f0e2c1a3b50>. (#1576, #8086)

  • The scrapy.utils.defer.parallel() and scrapy.utils.defer.parallel_async() functions, now deprecated, return a Deferred that fires with None, instead of with the result list of a DeferredList. (#5182, #7959)

  • The process_response() method of HttpCompressionMiddleware is now a coroutine function. Code that calls it must now await it, and subclasses that override it and call super().process_response() must now be async def. (#3751, #8153)

  • The item_scraped() method of scrapy.extensions.feedexport.FeedExporter, and the start_exporting() and finish_exporting() methods of scrapy.extensions.feedexport.FeedSlot, are now coroutine functions. (#5622, #6273, #7800)

  • parent_id is now part of Request.attributes, so Request.replace() and request_from_dict() pass a parent_id keyword argument to the request class. Request subclasses whose __init__() method accepts neither parent_id nor **kwargs must be updated. (#8225)

  • Item exporters now turn the values of fields without a serializer into lists if they are list-like, e.g. tuples or sets, and into dictionaries if they are items, recursively. This changes the output of PickleItemExporter, MarshalItemExporter, PprintItemExporter and custom BaseItemExporter subclasses, and CsvItemExporter now joins list-like values, e.g. sets, the way it joins lists. (#3888, #3890, #8057)

  • The output of a request errback that runs because a download failed now goes through the process_spider_output() methods of spider middlewares, with None as the response, and exceptions raised while iterating that output reach their process_spider_exception() methods. Spider middlewares whose methods expect a response must now also handle None. Built-in spider middlewares now also process that output, e.g. UrlLengthMiddleware can drop requests from such errbacks, and StartSpiderMiddleware now sets is_start_request in its process_start() method instead of in get_processed_request(). (#4999, #7992)

  • Feed storages now refuse feed modes that they do not support, which prevents the crawl from starting. In particular, setting the overwrite feed option to False for an S3 feed, which used to log a warning, now raises ValueError. For a GCS feed, which used to log a warning and overwrite the file, it now appends to the file. (#5580, #7826, #8173)

  • sitemap_follow now also filters the sitemap URLs declared in robots.txt files. If you set it, make sure it matches the URLs of the sitemaps declared in the robots.txt files that you want to follow. (#1182, #8175)

  • The process_request() method of HttpCacheMiddleware is now a coroutine function. Code that calls it must now await it, and subclasses that override it and call super().process_request() must now be async def. (#2744, #7915)

  • XMLFeedSpider.parse_nodes() and CSVFeedSpider.parse_rows() are now asynchronous generators. Code that calls them must now iterate over their output with async for. (#8392)

  • The settings of the built-in storages of media pipelines are no longer set as class attributes of those storages, e.g. S3FilesStore.POLICY keeps its default value regardless of FILES_STORE_S3_ACL. Read them from the storage object of the pipeline instead, e.g. pipeline.store.POLICY. (#7925)

  • Scraper.slot and the deprecated scrapy.core.scraper.Slot class now take a Crawler object instead of a maximum active size, their finish_response() method no longer takes a result parameter, their MIN_RESPONSE_SIZE attribute was removed, and their deprecated active_size attribute is read-only. (#6430)

  • The engine status that the telnet console reports now includes engine.response_active_size instead of engine.scraper.slot.active_size and engine.scraper.slot.needs_backout(). (#6430)

  • The deprecated METAREFRESH_IGNORE_TAGS setting and the ignore_tags parameter of the deprecated scrapy.utils.response.get_meta_refresh() function now raise ValueError for tags other than script, noscript and template, and only whether noscript is listed has any effect. METAREFRESH_IGNORE_TAGS is ignored altogether if METAREFRESH_SCRIPTING is set with the same or a higher priority. (#8393)

  • Scrapy no longer calls the deprecated spider_opened() and spider_closed() methods of SpiderState, so overriding them in a subclass has no effect. Handle the spider_state_loaded and spider_state_saving signals instead. (#5153, #7650, #7656)

  • Due to the new minimum version of w3lib, 2.6.0:

    • Request URLs are now normalized the way web browsers normalize them, so Request.url and Response.url can differ from the URL you pass, e.g. https://EXAMPLE.com becomes https://example.com/, https://example.com/a/../b becomes https://example.com/b, and https://0x7f.1/ becomes https://127.0.0.1/. Update any code that compares request or response URLs to literal strings.

    • Request fingerprints might differ for some URLs, so that cached responses of HttpCacheMiddleware and the seen requests of a job directory from an earlier version might not match the same requests.

    (#8393)

  • For encodings declared in the response, TextResponse.encoding now reports the Python codec names of the encodings that web browsers use, e.g. gbk instead of gb18030 for a gb2312 label, and utf-16-le instead of utf-16. It also reports utf-8 instead of cp1252 when the response declares no encoding and its body is ASCII-only, e.g. empty. For encoding labels that web browsers decode as a single U+FFFD character, like hz, it reports replacement, which raises UnicodeDecodeError when decoding any non-empty body, so use TextResponse.text instead of response.body.decode(response.encoding).

    TextResponse.text can also differ:

    • The detected encoding of responses that declare none and are not valid UTF-8 can change.

    • Encodings that web browsers ignore, like utf-32 or cp437, are now ignored when declared, and the encoding is detected instead. A <meta> tag or XML declaration that declares UTF-16 now means UTF-8.

    • Encoding declarations in <meta> tags are now found past the first 4096 bytes of the response body.

    • Response bodies are decoded the way web browsers decode them, which for some encodings, like euc-jp, differs from Python codecs.

    (#8393)

  • The base URL of a response, used by TextResponse.urljoin(), selectors and link extractors, and the meta refresh that MetaRefreshMiddleware follows, are now found closer to the way web browsers find them. In particular, they are now found anywhere in the response body, instead of only in its first 4096 characters, the meta refresh with the shortest delay, and the last one among those with that delay, now wins over the first one, meta refreshes within <script> or <template> elements, or to the response URL itself, ignoring its fragment, are no longer followed, and the base URL is normalized like request URLs. (#8393)

  • The response attribute of Selector objects is now read-only. For the selector of a response, i.e. TextResponse.selector, it no longer keeps the response alive, and becomes None once nothing else refers to the response. (#8245)

  • A negative value of FILES_EXPIRES or IMAGES_EXPIRES now disables expiration, so that files are never downloaded again once fetched. Previously, it made files be downloaded again every time; set the setting to 0 for that. (#8046)

  • Crawls closed because start() raised an exception, or by CLOSESPIDER_ERRORCOUNT, now make the crawl and runspider commands exit with code 1. (#8082, #8203)

  • A blank line between contract lines in a callback docstring now starts a new batch of contracts, which needs its own @url line; otherwise, the contracts of that batch do not run.

    ContractsManager.extract_contracts() now returns a list of batches, each a list of contracts, and ContractsManager.from_method() now returns a list of requests instead of a request or None.

    (#768, #8043)

Deprecations

  • The following modules are deprecated, with no replacement:

    • scrapy.utils.benchserver

    • scrapy.utils.console

    • scrapy.utils.datatypes

    • scrapy.utils.display

    • scrapy.utils.ftp

    • scrapy.utils.gz

    • scrapy.utils.job

    • scrapy.utils.ossignal

    • scrapy.utils.sitemap

    • scrapy.utils.ssl

    • scrapy.utils.template

    • scrapy.utils.versions

    (#7766, #8135, #8146, #8270)

  • The following functions, classes and methods are deprecated, with no replacement:

    • scrapy.core.scraper.Scraper.handle_spider_error()

    • scrapy.spiders.sitemap.iterloc()

    • scrapy.utils.defer.aiter_errback()

    • scrapy.utils.defer.iter_errback()

    • scrapy.utils.defer.parallel()

    • scrapy.utils.defer.parallel_async()

    • scrapy.utils.python.MutableAsyncChain

    (#8175, #8288, #8350, #8363, #8414)

  • scrapy.utils.python.garbage_collect() is deprecated, use gc.collect() instead. (#8367)

  • Passing a coroutine to scrapy.utils.spider.iterate_spider_output(), for which it returns a Deferred instead of an iterable, is deprecated. Await the coroutine and pass its result instead. (#8394)

  • Passing a synchronous iterable to scrapy.core.scraper.Scraper.handle_spider_output_async() is deprecated, pass an asynchronous iterable instead. (#8288)

  • scrapy.utils.reactor.is_asyncio_reactor_installed() is deprecated. To check for asyncio support, use is_asyncio_available(). To check whether a reactor is installed, use scrapy.utils.reactor.is_reactor_installed(). See Supporting older Scrapy versions for code that must also support older Scrapy versions. (#8128, #8454)

  • Defining a parse_item() method in a XMLFeedSpider subclass is deprecated. Define parse_node() instead. (#8147)

  • Exceptions that the process_response() method of a downloader middleware raises can now reach the process_exception() methods of the downloader middlewares that have not processed the response yet, so that RetryMiddleware can retry them. Because existing process_exception() methods may not expect those exceptions, e.g. the IgnoreRequest raised to drop a response, this only happens when the new DOWNLOADER_MIDDLEWARE_RESPONSE_EXCEPTIONS setting is True. Its default value, False, is deprecated, and a warning is issued when an exception would reach the process_exception() method of a non-Scrapy downloader middleware if the setting were True. Check that those methods handle such exceptions as intended, and set the setting to True. New projects generated with startproject already do. (#7790, #8177)

  • scrapy.utils.deprecate.create_deprecated_class() is deprecated, use formerly.deprecated_class() from formerly instead. scrapy.utils.decorators.deprecated() is deprecated, use warnings.deprecated() instead (or typing_extensions.deprecated() on Python 3.12 and lower). (#7894)

  • scrapy.utils.url.add_http_if_no_scheme() is deprecated. Use w3lib.url.add_http_if_no_scheme() instead. (#2186, #8189)

  • The following methods of Headers are deprecated:

    • fromkeys(): pass (key, value) pairs to Headers instead.

    • has_key(): use the in operator instead.

    • normkey() and normvalue().

    • setlist(): assign the list instead, e.g. headers[key] = values.

    • setlistdefault(): use setdefault() instead.

    • to_unicode_dict(): use to_tuple_list() instead.

    (#8259, #8264)

  • The spider_closed_callback parameter of ExecutionEngine is deprecated. Closing the spider now stops the engine, and Crawler.crawl_async() completes when that happens. (#6916, #8217)

  • Setting the ExecutionEngine.running attribute is deprecated, and has no effect. (#8181)

  • Custom schedulers that do not set supports_skip_dupefilter_once to True are deprecated, including subclasses of the default scheduler that override its enqueue_request() method. Scrapy turns skip_dupefilter_once into dont_filter=True for them, with a warning. To update a scheduler, handle skip_dupefilter_once in its enqueue_request() method and set supports_skip_dupefilter_once to True. (#6895, #8224)

  • The overwrite feed option is deprecated. Use the new mode feed option instead: "overwrite" instead of True, "append" instead of False. The overwrite attribute of FTPFeedStorage is deprecated as well.

    The default value of the new FEED_MODE setting, None, is also deprecated: it will change to "create" in a future version of Scrapy, so that existing feed targets are not modified. Set FEED_MODE, or the mode option of every feed, to silence the deprecation warning. New projects set FEED_MODE to "create" in their settings.py file. (#5580, #7826)

  • The STORE_SCHEMES attribute of FilesPipeline is deprecated. Use the new MEDIA_STORAGES setting instead. (#5991, #7925)

  • The spider_opened() and spider_closed() methods of SpiderState are deprecated. Use the new spider_state_loaded and spider_state_saving signals instead. (#5153, #7650, #7656)

  • The spider and to_native_str_type parameters of scrapy.robotstxt.decode_robotstxt() are deprecated and have no effect. (#8316)

  • Calling AsyncCrawlerRunner.crawl() without a running asyncio event loop while TWISTED_REACTOR_ENABLED is False is deprecated. Call it from a coroutine that runs in the event loop instead, e.g. one passed to asyncio.run(). (#7201, #7681, #8327)

  • ImagesPipeline.convert_image() has a new image_format keyword-only parameter with the original image format. Overriding the method without that parameter, and calling it without it, are deprecated. (#8198, #8457)

  • The SCRAPER_SLOT_MAX_ACTIVE_SIZE setting is deprecated. Use RESPONSE_MAX_ACTIVE_SIZE instead.

    scrapy.core.scraper.Slot is deprecated as well, and so are the active_size and max_active_size attributes and the needs_backout() method of Scraper.slot. Use ExecutionEngine.response_active_size, RESPONSE_MAX_ACTIVE_SIZE and ExecutionEngine.needs_backout() instead.

    (#6430)

  • Using a Twisted reactor other than AsyncioSelectorReactor is deprecated, be it set through the TWISTED_REACTOR setting, installed by code outside Scrapy, or passed to install_reactor(). Setting TWISTED_REACTOR to None or "" is deprecated as well. Remove any custom TWISTED_REACTOR setting from your code.

    The FORCE_CRAWLER_PROCESS setting is deprecated as well.

    (#8111, #8454)

  • Passing an encoding that web browsers do not support, e.g. cp437, to the encoding parameter of TextResponse is deprecated. To decode a response body with such an encoding, use response.body.decode(encoding). (#8393)

  • scrapy.utils.response.get_base_url() and scrapy.utils.response.get_meta_refresh() are deprecated. Use the new TextResponse.base_url and TextResponse.meta_refresh attributes instead. When there is no meta refresh, the latter is None instead of (None, None). (#8393)

  • The METAREFRESH_IGNORE_TAGS setting is deprecated. Use the new METAREFRESH_SCRIPTING setting instead. (#8393)

New features

  • Request objects can now be awaited, e.g. in a spider callback, to send them and get their response. See Inline requests. (#1144, #8207)

  • Added a DOWNLOAD_HANDLERS_BY_NAME setting and a download_handler request meta key, to choose a download handler per request, e.g. a browser-based handler for only some requests. The default request fingerprinter takes download_handler into account when it does not match the URL scheme.

    RobotsTxtMiddleware now copies download_handler from the request that triggers a robots.txt request, and sets the new is_robotstxt_request request meta key on the robots.txt requests that it sends.

    (#5510, #7885)

  • Added a body_file request meta key, which writes the response body into a file as it is downloaded, so that large responses can be downloaded without keeping them in memory, with download handlers that support it. Set it to a file path, or to True to write into a new temporary file. Those requests get a BodyFileResponse, and neither they nor their responses count toward RESPONSE_MAX_ACTIVE_SIZE. (#3880, #4620, #5044, #7987, #8466)

  • Sending a shutdown signal, e.g. with Ctrl+C, a second time now triggers a fast stop, which drops queued and in-progress downloads instead of waiting for them to finish. Sending it a third time forces an unclean shutdown, which used to happen on the second signal. Dropped requests are counted in the new downloader/request_dropped_count stat.

    Crawler.stop_async(), CrawlerRunner.stop() and AsyncCrawlerRunner.stop() have a new keyword-only mode parameter that can be "graceful" (the default), "fast" or "force", which works as "fast" unless you use CrawlerProcess or AsyncCrawlerProcess. stop_async() and close_spider_async() accept "graceful" and "fast". A custom DOWNLOADER class needs a stop() coroutine method, returning the number of dropped requests, for fast stops to drop its downloads. (#4749, #5000, #7455, #8296, #8312)

  • Added the delay request meta key, which holds a request for at least the given number of seconds before sending it, and the delayed request meta key, which lists the delays that a request has been held for. (#802, #3835, #4980, #5015, #7873)

  • Added TextResponse.base_url and TextResponse.meta_refresh, which return the base URL of a response and the MetaRefresh that a web browser with JavaScript enabled would follow, and which you can set to override what the response body says. When METAREFRESH_SCRIPTING is False, MetaRefreshMiddleware ignores an overridden meta_refresh. (#8393)

  • Added a METAREFRESH_SCRIPTING setting, which you can set to False to follow the meta refresh that a web browser with JavaScript disabled would follow. (#8393)

  • Added a FEED_MODE setting and a mode feed option, which set what happens when the target of a feed already exists: "append" to it, "overwrite" it, or "create", which leaves it untouched, logs an error and increases the feedexport/conflicts/<storage class> stat. Custom feed storages declare the modes that they support with the new supported_modes attribute.

    The -o command-line option also follows FEED_MODE, so in a project with FEED_MODE set to "create", -o leaves an existing file untouched. Use -O to overwrite it. (#5580, #7826)

  • Added DiskDupeFilter, a DUPEFILTER_CLASS that keeps request fingerprints in an SQLite database on disk instead of in memory, to lower memory usage on large crawls. (#5307, #7952)

  • Added a JOBDIR_SYNC_EVERY setting to write the active.json file of the job directory, and the database of DiskDupeFilter, while the crawl runs, so that a crawl killed before it can stop cleanly can resume from its latest state, provided that SCHEDULER_DISK_QUEUE and SCHEDULER_START_DISK_QUEUE use SQLite-based queues. Custom SCHEDULER_PRIORITY_QUEUE classes need the new changed attribute and state() method to support it.

    active.json is also now written atomically, so that it cannot be left half-written.

    (#7978, #8152, #8322)

  • Added Request.id, a unique identifier of each request, and Request.parent_id, the id of the request it derives from, which Scrapy sets for requests from callbacks and errbacks, from Response.follow() and from Request.replace(), e.g. redirects and retries. Use the new parent_id parameter of Request to set it on requests that your code builds on behalf of another request, e.g. in a downloader middleware. Both survive serialization, e.g. into the disk queues of a job directory. (#8225)

  • Added a genrequest command, which prints the Python code of a Request object equivalent to a cURL command, given as an argument or read from the system clipboard with the new clipboard extra. (#3990, #3991, #8058)

  • Added a complete command, which prints a shell completion script for Bash, fish or Zsh. Completion covers the spiders, settings and templates of the current project, and custom commands, which can provide their own candidates by overriding the new complete_argument() and complete_option() methods. It replaces the completion scripts that were in the extras directory of the source code repository. (#6453, #7899)

  • Added a STICKY_META_KEYS setting to copy request metadata keys from a response into the follow-up requests yielded by its callback, handled by the new StickyMetaParamsMiddleware.

    The new middleware has priority 1000 in SPIDER_MIDDLEWARES_BASE, and MetaCopyDetectionMiddleware moved from 1000 to 999.

    (#3645, #3770, #4141, #7711, #8166)

  • Rule has new name and from_rules parameters, to apply a rule only to responses reached through specific other rules. (#982, #8066)

  • A callback docstring can now define several batches of contracts, one per paragraph, and a batch can repeat @url to check the callback against more than one sample request. Custom contracts can set the new generates_request attribute of Contract to True to behave like @url. (#768, #8043)

  • The Google Cloud Storage feed storage now supports the "append" feed mode, instead of logging a warning and overwriting the feed. (#7823, #8173)

  • FILES_EXPIRES and IMAGES_EXPIRES now support fractional numbers of days, e.g. 0.5 for 12 hours, and negative values, which disable expiration, so that files are never downloaded again once fetched. (#2309, #4731, #8046)

  • The reactor_path parameter of install_reactor() is now optional, and defaults to the asyncio reactor. (#8125)

  • Added a DOWNLOADER_MIDDLEWARE_RESPONSE_EXCEPTIONS setting which, when True, passes exceptions raised by the process_response() method of a downloader middleware to the process_exception() methods of the downloader middlewares that have not processed the response yet. This allows RetryMiddleware to retry responses that other middlewares reject, e.g. responses that cannot be decompressed, for which DecompressionError is now part of RETRY_EXCEPTIONS. (#1900, #3506, #7790, #8177)

  • CloseSpider can now be raised from downloader middlewares to close the spider. (#2578, #8177)

  • Added JsonValidationMiddleware, with priority 560 in DOWNLOADER_MIDDLEWARES_BASE and enabled with the JSONVALIDATION_ENABLED setting, which raises json.JSONDecodeError for successful JsonResponse responses with an invalid JSON body. json.JSONDecodeError is now part of RETRY_EXCEPTIONS, so those responses are retried if DOWNLOADER_MIDDLEWARE_RESPONSE_EXCEPTIONS is True. (#8215)

  • Added an error keyword-only parameter to CloseSpider and close_spider_async(), to mark a crawl as failed. Failed crawls set the new finish_reason_error stat to True, get error=True in their spider_closed signal, and make the crawl and runspider commands exit with code 1. Crawls closed because start() raised an exception (start_error) are now also marked as failed, and so are crawls closed by CLOSESPIDER_ERRORCOUNT. (#1241, #2171, #3653, #3654, #8082, #8203, #8204, #8352, #8357)

  • Added an IMAGES_PRESERVE_FORMAT setting to keep images in their original format instead of converting them to JPEG. Stored images then get no file extension. (#1705, #2471, #8198)

  • Added an item_processor feed option to replace each item with any number of items in a given feed, and a feedexport/item_count/<storage class> stat with the number of exported entries per storage class. (#5905, #7911)

  • Added an UPLOAD_TIMEOUT setting to set how long uploads to remote feed storages and media pipeline storages (Amazon S3, Google Cloud Storage and FTP) wait for a response before giving up. (#5011, #8162)

  • Added a MEDIA_CACHE_SIZE setting to limit how many download outcomes media pipelines keep in memory, which by default they keep for the whole crawl. (#939, #8193)

  • LOG_FORMAT now supports a %(spider)s placeholder with the name of the spider that triggered the log message, or - for messages not tied to a spider. (#1576, #8086)

  • StatsCollector objects are now mutable mappings of stats, e.g. stats["hostname"] = socket.gethostname(). (#3230, #8241)

  • The start_exporting(), export_item() and finish_exporting() methods of item exporters used by feed exports, and the open() and store() methods of feed storages, can now be coroutine functions. (#5622, #6273, #7800)

  • Added a LOG_LEVELS setting, to set the minimum log level of specific loggers, overriding the levels that Scrapy sets by default. (#2231, #7921)

  • The settings command now takes the settings of enabled add-ons into account, and has a new --spider option to take the settings of a spider into account as well. (#7010, #7828)

  • Added a skip_dupefilter_once request meta key, which skips duplicate filtering for a request without affecting the requests derived from it, and a supports_skip_dupefilter_once attribute for schedulers to declare that they support it. (#6895, #8224)

  • The FTP download handlers now list the contents of a directory when the URL path is empty or ends in /, returning the output of the FTP NLST command, one name per line. (#1478, #2505, #8197)

  • The memory usage extension now works on Windows, with the new memusage extra. (#4070, #8062)

  • Added EngineState and ExecutionEngine.state, which tell the lifecycle state of the engine. (#6916, #8217)

  • The fetch, view, shell and parse commands now support a --curl option, to build the request from a cURL command instead of from a URL argument. (#36, #447, #7703)

  • Added an experimental FTP and FTPS download handler, AioftpDownloadHandler, used by default when running without a Twisted reactor. The new socks extra enables its support for SOCKS proxies. (#7261, #8213, #8341)

  • Added MEDIA_STORAGES and MEDIA_STORAGES_BASE settings, which map URL schemes to the storage classes of the media pipelines, to support additional schemes or replace built-in storages. Storage classes can define a from_crawler() class method to read settings, including settings specific to the files or images pipeline, or to a pipeline subclass.

    Pipelines no longer share the settings of built-in storages, so that e.g. the files and images pipelines of a crawl can use different values for FILES_STORE_S3_ACL and IMAGES_STORE_S3_ACL. (#5991, #7925)

  • Added FILES_CHECKSUM_ALGORITHM and IMAGES_CHECKSUM_ALGORITHM settings, to calculate the checksums of media pipeline files with a hashlib algorithm other than MD5. (#3306, #7951)

  • LxmlLinkExtractor has a new schemes parameter to choose the URL schemes of extracted links, and scrapy.linkextractors.SUPPORTED_SCHEMES lists the URL schemes that Scrapy can download out of the box. (#4979, #7994)

  • Added SitemapSpider.sitemap_request(), which you can override to customize the requests that SitemapSpider builds from sitemap entries, e.g. to pass sitemap data to callbacks. (#2565, #3543, #8175)

  • Added a sitemaps() method to RobotParser, implemented by the Protego and Robotexclusionrulesparser parsers, which returns the sitemap URLs declared in the robots.txt file, and a response parameter to the robots_parsed signal. (#3967, #8069, #8175)

  • Added the spider_state_loaded, spider_state_saving and feed_slots_initialized signals. (#5153, #7650, #7656)

  • Added an event loop lag monitor extension, enabled by default, which logs a warning when code blocks the event loop for longer than the new EVENT_LOOP_LAG_THRESHOLD setting, 10 seconds by default. (#3197, #8093)

  • When RobotsTxtMiddleware denies at least one start request and no start request can be crawled, the crawl now finishes with the robotstxt_denied finish_reason instead of finished, and an error is logged. (#6164)

  • urlparse_cached() now also accepts a URL string, and scrapy.utils.url.url_is_from_any_domain(), url_is_from_spider() and url_has_any_extension() now also accept Request and Response objects. Built-in components now reuse URL parsing results more, which makes crawls faster. (#8247)

  • Added a proxy_headers request meta key, to send headers to the proxy set in proxy, e.g. in the CONNECT request of HTTPS URLs. (#3329, #7888)

  • Added UriUserInfoMiddleware, enabled by default, which removes the credentials from request URLs like https://user:pass@example.com and sets them as http_user and http_pass, or as ftp_user and ftp_password for FTP URLs. As a result, Request.url and Response.url no longer include those credentials after that middleware. (#669, #851, #1466, #4474)

  • Added an HTTPCACHE_SCOPE setting, which allows sharing the HTTP cache across spiders and, with FilesystemCacheStorage, splitting it by request host instead of by spider. (#5166, #5175, #7964)

  • Added a LOG_ROOT_FORMATTER setting, which sets the formatter of the root log handler. Such formatters implement the new LogRootFormatterProtocol, and the new LogRootFormatter is the default one, which you can also use in your own log handlers. LOG_COLOR also works with custom formatters. (#8336)

  • Added a CONNECTION_KEEPALIVE_TIMEOUT setting, which sets how long the built-in HTTP download handlers keep idle connections open for reuse. Its default value, 240 seconds, is the timeout that the Twisted-based handlers already used; the aiohttp- and httpx-based handlers used their library defaults, 15 and 5 seconds respectively. (#8342)

  • Added Response.follow_redirect(), which returns a request that follows the Location header of the response. (#8331)

  • When DOWNLOAD_FAIL_ON_DATALOSS or the download_fail_on_dataloss request meta key is False, hitting the download timeout while receiving the response body now returns the part of the response received so far, with the dataloss flag, instead of raising DownloadTimeoutError, with all built-in download handlers except FTPDownloadHandler. (#3407, #3492, #8084, #8464)

  • HTTP11DownloadHandler now supports proxies with an IPv6 address, proxies whose host name only resolves to IPv6 addresses, given an IPv6-capable TWISTED_DNS_RESOLVER, and HTTPS requests to IPv6 addresses through a proxy. (#6674, #7090, #8116, #8343)

  • When asyncio support is available and aioboto3 is installed, S3 feed storage uploads files with it, instead of running boto3 in a thread. Similarly, the S3 storage of media pipelines uses aiobotocore, when installed, instead of botocore. (#3845, #8330, #8339)

  • Added a CONCURRENT_CONNECTIONS_PER_HANDLER setting, which limits the number of connections, idle ones included, that each download handler keeps open. By default, the limit is derived from the maximum number of open files allowed for the process, or from the select.select() limit on Windows, to prevent Too many open files errors (see I get too many file descriptors in select() or Too many open files). (#2653, #5024, #5618, #7932)

  • Added a REDIRECT_HTTP_CODES setting and a redirect_http_codes request meta key, which set the response status codes whose Location header RedirectMiddleware follows, e.g. to follow the Location header of 201 responses. Media pipelines with MEDIA_ALLOW_REDIRECTS enabled leave responses with those status codes to RedirectMiddleware. (#1615, #7801)

  • HTTP11DownloadHandler now supports https:// proxy URLs for https:// destination URLs. (#5828, #7776)

  • When several requests for the same resource are sent concurrently, HttpCacheMiddleware now downloads it only once, and, if the response is cached, serves it from the cache to the other requests. The new httpcache/wait stat counts the requests that waited for another one. (#2744, #7915)

  • XMLFeedSpider.parse_node(), CSVFeedSpider.parse_row() and the errback of Rule can now be defined as coroutine functions (async def) or asynchronous generator functions. (#8392)

  • item_completed() in subclasses of MediaPipeline can now be defined as a coroutine function (async def), and stat_file() in custom media storages can now await asyncio code. (#8413)

  • BaseSettings.getlist() now parses a string that is a JSON list, e.g. -s 'MY_LIST=["a,b", "c"]', so that items that contain commas can be set from the command line. (#8416)

  • Added a RESPONSE_ROUGH_SIZE setting, the ExecutionEngine.response_active_size attribute, and the request_backout_seconds/concurrency, request_backout_seconds/response_max_active_size and request_backout_seconds/total stats. See Identifying crawl bottlenecks. (#5302, #6206, #6430)

Improvements

  • The encoding of a response that doesn’t declare one is now detected the way web browsers do: UTF-8 if the body is valid UTF-8, otherwise a guess based on the body and on the top-level domain of the response URL, as Firefox does. Encoding declarations in <meta> tags are also found the way web browsers find them, and declared encoding names are mapped to encodings the way web browsers map them, e.g. gb2312 to GBK instead of GB18030. (#8393)

  • With parsel 1.12.0+, Selector objects created from a UTF-8 response now parse the response body as is, instead of decoding it first, which saves time and memory. (#5906, #8195, #8222, #8393)

  • Responses are now freed as soon as nothing refers to them, also after using their selector or after their callback raises an exception, instead of when the garbage collector runs, which lowers peak memory usage. (#2977, #8245)

  • The reactor settings DNSCACHE_ENABLED, DNSCACHE_SIZE, DNS_TIMEOUT, REACTOR_THREADPOOL_MAXSIZE and TWISTED_DNS_RESOLVER can now be set from a spider when using CrawlerProcess or AsyncCrawlerProcess. When running multiple spiders in the same process, the values of the first spider are used, and a warning is issued for any later spider that defines a different value. The DNS resolver now gets the Crawler of that first spider in its from_crawler() method. (#5988, #7923)

  • The runspider command now accepts file paths without an extension, such as the ones of Bash process substitution (scrapy runspider <(…)). (#4827, #8036)

  • Items are now processed by tasks started on demand, instead of by a fixed number of tasks, one per CONCURRENT_ITEMS, started for every response, so a high CONCURRENT_ITEMS value no longer slows down crawls. CONCURRENT_ITEMS values lower than 1 now work as 1. (#5182, #7959)

  • Exceptions raised while exporting an item to a feed now include the item in a note. (#2775, #8191)

  • When a TextResponse is created with a str body and a UTF-8 encoding, that body is now reused as text instead of being decoded again. (#8220)

  • Improved the performance of link extraction with LxmlLinkExtractor. (#8126)

  • Compressed response bodies of 8 KiB or more are now decompressed in a thread, so that other responses can be processed meanwhile. (#3751, #8153)

  • The Scrapy version and the versions of LOG_VERSIONS are now logged when each crawler is set up, after add-ons and spider settings are applied, so that they can change BOT_NAME and LOG_VERSIONS. They are now also logged when using CrawlerRunner or AsyncCrawlerRunner. Add-ons can now log the versions of their dependencies. (#8246)

  • scrapy.pipelines.files.S3FilesStore now supports any header that botocore supports for uploads, and media pipelines now document how to set custom headers for files uploaded to Amazon S3. (#4788, #4813, #8171)

  • H2DownloadHandler now sends the Content-Length request header that you set, instead of replacing it, with a warning, with one built from the request body. (#4919, #7944)

  • H2DownloadHandler now supports DOWNLOAD_FAIL_ON_DATALOSS and the download_fail_on_dataloss request meta key: when the setting or meta key is False, responses cut short by a lost connection are now returned with the dataloss flag; otherwise, they now fail with ResponseDataLossError instead of DownloadFailedError. HTTP/2 data loss is now also detected by HttpxDownloadHandler. (#5048, #7989)

  • Spiders that request the robots.txt file of a host, like SitemapSpider, no longer download it twice when ROBOTSTXT_OBEY is True: RobotsTxtMiddleware now parses the response of a request for the robots.txt file of a host, if it has not downloaded it yet, instead of downloading it again. (#3967, #8069)

  • Requests that set the download_maxsize request meta key but not download_warnsize no longer log a warning based on DOWNLOAD_WARNSIZE. (#8213)

  • AiohttpDownloadHandler is now lazy. (#8346)

  • Connecting a handler to a built-in signal, where the handler declares an argument which the signal never sends, e.g. because of a typo, now issues a warning. (#8345)

  • call_later() and the processing of the output of spider callbacks now run in the contextvars context that was current when they were scheduled also when not using the asyncio reactor, so that context variables set by your code, e.g. for tracing or logging, are kept. (#8347)

  • Improved the performance of scrapy.utils.python.binary_is_text(), which is used to pick the class of responses. (#8362)

  • CookiesMiddleware now ignores received cookies with a __Secure- or __Host- name prefix that do not meet the requirements of that prefix, as web browsers do, e.g. such cookies received over plain HTTP. (#5431, #8431)

  • Improved the performance of feed exports, especially for items with scalar field values. (#8461)

  • Improved the performance of StatsCollector method calls. (#8243)

  • Other code refactoring and improvements. (#8262, #8263, #8295, #8313, #8323, #8335, #8353, #8365, #8385, #8391, #8415)

Bug fixes

  • FTPDownloadHandler now raises DownloadFailedError when the server drops the connection, so that those downloads are retried. (#1511, #8206)

  • FilesPipeline now treats responses with the 201 status code as successful downloads. (#8349)

  • The Cookie header now lists cookies with the same path length from oldest to newest, as RFC 6265 Section 5.4 requires. (#5431, #8321)

  • The runspider command now runs the given file even if its name matches that of an already imported module, e.g. json.py. (#8036, #8463)

  • The check command now reports errors that prevent a spider from crawling, e.g. errors raised while creating the spider, instead of silently ignoring them. (#3716, #7991)

  • Request.from_curl() now handles headers without a value (-H 'Name;') as curl does, ignores headers that curl would not send, supports -u with a user name and no password, and raises ValueError for an empty command, instead of failing with unexpected exceptions. It also turns -H 'Name:' into a header set to None, i.e. not sent, instead of a header with an empty value, accepts Bash $'…' quoting in any argument, e.g. headers, although it does not decode backslash escapes, and keeps a leading $ in request data instead of removing it.

    Request.to_curl() now includes every value of repeated headers, handles headers set to None and no longer fails on headers that are not valid UTF-8.

    (#8131, #8138, #8148, #8267, #8291, #8292)

  • Headers.to_tuple_list() no longer raises UnicodeDecodeError; bytes that cannot be decoded are replaced with U+FFFD. (#2592, #2637, #8192)

  • copy.copy() on an Item now returns a shallow copy, like Item.copy(). It used to return an item that shared its fields with the original, so that setting or deleting a field on one also did it on the other. (#8172)

  • Calling exit() or quit() in the telnet console now closes the connection, instead of logging an unhandled error. (#3853, #8065)

  • An exception raised while building the SCHEDULER is now reported as is, instead of being followed by a RuntimeError about an unassigned engine slot. (#8169)

  • The lastseen field of the representation of a downloader slot, e.g. in the telnet console, now shows the monotonic timestamp of the last activity instead of a meaningless date. (#8182)

  • SitemapSpider now resolves relative and protocol-relative URLs in sitemaps against the sitemap URL. (#965, #8210)

  • CrawlSpider now follows the links of a response also when the callback of the matching rule raises an exception. (#4108, #8200)

  • A feed URI with a placeholder that is neither a spider attribute nor returned by the uri_params function now makes only that feed be skipped, with an error logged, instead of raising KeyError and leaving the remaining feeds unopened. (#2089, #8205)

  • Fixed the file modification times that FilesPipeline reads from Amazon S3, Google Cloud Storage and FTP storages to apply FILES_EXPIRES. S3 and Google Cloud Storage times were off by the UTC offset of the local time zone, and FTP times were misread. (#8186, #8196)

  • Lines of a callback docstring that start with @ but do not name a registered contract, e.g. a decorator in a code example, are now ignored, instead of raising KeyError or making the check command treat the callback as having contracts. As a result, a misspelled contract name is also ignored. (#8226)

  • The bench command now listens on a random free port, instead of failing when port 8998 is in use. (#8230)

  • CONCURRENT_REQUESTS_PER_DOMAIN and the concurrency key of DOWNLOAD_SLOTS are now enforced when using asyncio with no download delay. (#8256, #8257)

  • SitemapSpider now detects XML sitemaps also in responses that are not XmlResponse objects, e.g. from third-party download handlers, based on their headers, URL and body. (#6362, #7904)

  • Fixed the handling of headers that are not valid UTF-8 or ASCII in some download handlers:

    • HttpxDownloadHandler no longer fails on non-ASCII request headers.

    • AiohttpDownloadHandler no longer fails on request or response headers that are not valid UTF-8. Invalid UTF-8 in request headers is sent as U+FFFD, with a warning.

    • H2DownloadHandler no longer fails, or hangs, on request or response headers that are not valid UTF-8.

    (#8265)

  • Headers.get() now returns the given default value for a header set to None. (#8268)

  • Fixed the downloader/request_bytes and downloader/response_bytes stats, which miscounted line breaks for requests with all headers set to None and for responses with multi-value headers, and scrapy.utils.request.request_httprepr(), which added an extra line break for requests with all headers set to None. (#8266, #8271)

  • Changing the header values in the output of Request.to_dict() or Response.to_dict() no longer changes the original request or response. (#8269)

  • HTTP11DownloadHandler now closes the proxy connection of an HTTPS request that times out, or is otherwise cancelled, before the proxy has established the tunnel. (#3614, #7810)

  • RedirectMiddleware no longer copies the fragment of the original URL into the redirect URL when the Location header ends with an empty fragment (#). (#8100)

  • When using a job directory, the default scheduler now pops requests by priority across its memory and disk queues, instead of popping every request from the memory queue before any from the disk queue.

    Custom SCHEDULER_PRIORITY_QUEUE classes need to implement the new next_priority() method to get this behavior. PriorityQueueProtocol documents the interface of priority queue classes. (#3666, #8237)

  • When resuming a crawl from a job directory, feeds whose URI uses %(batch_id)d now continue the batch numbering of the previous run, instead of starting from 1 again and overwriting the existing files. (#5153, #7650, #7656)

  • Item exporters now serialize nested items, and lists of them, using the serializers declared in their own fields. (#3888, #3890, #8057)

  • Fixed AsyncioLoopingCall sometimes calling its function twice in a row when the event loop woke it up slightly early, which could, for example, close a spider because of CLOSESPIDER_TIMEOUT_NO_ITEM while it was still producing items. (#8294)

  • The RobotFileParser parser now ignores the invalid bytes of a robots.txt file that is not valid UTF-8, like the other built-in parsers, instead of ignoring the whole file. (#8316)

  • Exceptions raised while handling the output of a spider callback, e.g. by a custom scheduler or log formatter, are now logged, and no longer interfere with the handling of the rest of that output. (#8318)

  • Scrapy now uses the event loop of the installed asyncio reactor when no event loop is running, instead of the current event loop of the thread, which can be a different one or none at all, e.g. when the reactor was installed with a loop that is not set as the current one. (#7201, #8324, #8325)

  • Stopping a crawl while an item yielded from start() is going through the item pipelines no longer hangs. (#8348)

  • H2DownloadHandler now fails requests with the connection error when it cannot connect to the server, instead of letting them hit the download timeout, and later requests to the same server try to connect again. (#8332)

  • Fixed ScrapyPriorityQueue, which the default DownloaderAwarePriorityQueue uses for each download slot, returning no request or a request other than the one that its peek() method returned, which could happen with requests of the same priority in its start request and regular request queues, or after a request failed to be serialized into a disk queue. (#7837)

  • The telnet console, and any other caller of scrapy.utils.reactor.listen_tcp(), now tries the next port when another process starts listening on the same port at the same time, instead of failing to start. (#8356)

  • Fixed RobotsTxtMiddleware letting through requests disallowed by robots.txt when they were sent while the robots.txt file of their website was being downloaded for another request. (#8297, #8386)

  • SitemapSpider now only treats links with rel="alternate" as alternate links, instead of any link, e.g. canonical ones, both when sitemap_alternate_links is enabled and in the entries passed to sitemap_filter(). (#8390)

  • Download handlers are now closed when the engine is closed without having been started, e.g. when opening the spider fails, and the downloader is now closed when the engine is stopped without a spider. (#8167, #8377)

  • The spider is no longer considered idle, and so no longer closed, while a request taken from the scheduler has not reached the downloader yet, which could happen with a custom DOWNLOADER. (#8315, #8355)

  • The reactorless shell now waits for the engine to start before letting you use it. (#8168)

  • On Windows, AiohttpDownloadHandler no longer connects to the wrong port in rare cases. (#8382)

  • The Scrapy shell no longer uses ptpython on Windows when the standard output is not a console, which ptpython does not support. (#8367)

Documentation

Quality assurance

Scrapy 2.19.0 (2026-09-10)

Highlights:

  • New RemoteControl extension which allows inspecting and controlling a running crawl over HTTP, used by the Scrapy MCP server

  • Experimental aiohttp-based download handler (now the default when running without a reactor)

Modified requirements

Backward-incompatible changes

  • When running without a Twisted reactor, i.e. with TWISTED_REACTOR_ENABLED set to False, the default download handler for http and https is now AiohttpDownloadHandler instead of HttpxDownloadHandler. You can configure HttpxDownloadHandler in the DOWNLOAD_HANDLERS setting if you want. (#8118)

  • scrapy.http.cookies.WrappedRequest.is_unverifiable() now always returns False, and the undocumented is_unverifiable request meta key that it used to read is ignored. (#7933)

Deprecations

  • The RANDOMIZE_DOWNLOAD_DELAY setting is deprecated. Use the new DOWNLOAD_DELAY_JITTER setting instead. Similarly, the randomize_delay key of the DOWNLOAD_SLOTS setting is deprecated in favor of a new jitter key, the randomize_delay attribute of scrapy.core.downloader.Slot is deprecated in favor of its new jitter attribute, and the randomize_delay attribute of scrapy.core.downloader.Downloader is deprecated in favor of the DOWNLOAD_DELAY_JITTER setting. (#7881)

  • The install_root_handler parameter of configure_logging(), CrawlerProcess and AsyncCrawlerProcess is deprecated. Use the new LOG_INSTALL_ROOT_HANDLER setting instead. (#4793, #8041)

  • The scrapy.dupefilters.RFPDupeFilter.fingerprints attribute is deprecated. Overriding scrapy.dupefilters.RFPDupeFilter.request_fingerprint() is deprecated as well; set the REQUEST_FINGERPRINTER_CLASS setting instead. (#5517, #7943)

  • Overriding the add_pre_hook() or add_post_hook() methods of Contract is deprecated. Define pre_process() or post_process() instead. (#6681, #7886)

New features

  • Added a RemoteControl extension, enabled by default, which allows connecting to crawl processes via HTTP and running code inside them. (#7866)

  • Added an experimental HTTP download handler based on aiohttp, AiohttpDownloadHandler. (#8118)

  • Added SQLite-backed scheduler queues: PickleFifoSQLiteQueue, PickleLifoSQLiteQueue, MarshalFifoSQLiteQueue and MarshalLifoSQLiteQueue. They write each request within its own transaction, so that an unclean shutdown cannot corrupt the on-disk queue, at the cost of slower scheduling. (#845, #7877)

  • Added a DOWNLOAD_DELAY_JITTER setting, and a jitter key for DOWNLOAD_SLOTS, which set the magnitude of the random variation applied to DOWNLOAD_DELAY. They replace the RANDOMIZE_DOWNLOAD_DELAY setting and the randomize_delay key, which could only toggle a fixed ±50%. (#7881)

  • Added a LOG_COLOR setting, which colorizes log output by log level when logging to a terminal. It needs the new color extra. (#8091)

  • The encoding of a response that doesn’t declare one is now detected with charset-normalizer when the response body is neither ASCII nor UTF-8, instead of always falling back to cp1252. (#3135, #8054)

  • Added a LOG_INSTALL_ROOT_HANDLER setting, which replaces the deprecated install_root_handler parameter and, unlike it, can also be set from a settings.py module or from the command line. (#4793, #8041)

  • Contracts now support callbacks defined with async def, including asynchronous generators. (#6681, #7886)

  • Added the MethodContract (@method), BodyContract (@body), HeaderContract (@header) and CookieContract (@cookie) contracts, which set the corresponding attributes of the sample request, and an -a option for the check command, to set spider arguments as in the crawl command. (#1918, #8053)

  • Added Response.to_dict(), Response.from_dict() and response_from_dict(), and used them in the built-in HTTP cache storages, which now restore cached responses of any response class, including those of third-party plugins, with all their attributes. (#1450, #7908)

  • Cached responses now indicate when they were stored, through the new cache_timestamp request meta key. (#2221, #8034)

  • The format key of FEEDS is now inferred from the file extension of the feed URI when not set, e.g. json for a URI ending in .json. (#1158, #8031)

  • Added find_projects(), which yields the root directory of every Scrapy project in a directory tree. (#8024)

  • Added a public scheduler attribute to ExecutionEngine. (#8099)

  • StatsCollector objects now implement __str__(), which returns the pretty-printed stats. (#2746)

  • open_in_browser() now also supports responses that are neither HTML nor plain text, picking a file extension based on the Content-Type header. (#3902, #8067)

  • The -t/--template option of the genspider command now also takes a path to a .tmpl file, so that a custom template can be used without setting TEMPLATES_DIR. (#8071)

  • The --pdb command-line option now uses ipdb instead of pdb when ipdb is installed. (#4284, #8052)

  • Log records about item processing, i.e. about items scraped, dropped or raising an exception, now carry the item in their extra dict, under the item key, so that custom logging handlers can read it. (#8085)

Improvements

  • RFPDupeFilter now keeps request fingerprints as bytes, to reduce memory usage. The requests.seen file that it writes in the job directory is now a binary file. (#5517, #7943)

  • The --pdb command-line option now starts a post-mortem debugging session on every logged error that comes with a traceback, instead of on every Failure object built anywhere in the process. (#3552, #8037)

  • The Scrapy shell no longer prints the DEBUG messages of parso, an indirect dependency of IPython, when LOG_LEVEL is DEBUG. (#8060)

  • Other code refactoring and improvements. (#8123)

Bug fixes

  • HTTP11DownloadHandler now sets certificate and ip_address attributes even for responses without a body. (#4466, #8048)

  • HTTP connection pool keys in HTTP11DownloadHandler and H2DownloadHandler now include the request bind address (see DOWNLOAD_BIND_ADDRESS), so that requests bound to different addresses no longer reuse each other’s pooled connections. (#3565, #8081)

  • HttpCacheMiddleware now updates the headers of a cached response, and stores it again, when a revalidation request gets a 304 response. (#3778, #8068)

  • An exception raised in a spider callback that no process_spider_exception() method handles is now offered to each of those methods only once. (#4729, #7996)

  • Defining allowed_domains as a property no longer breaks the commands that match a URL to a spider, i.e. shell, fetch and parse. A property cannot be evaluated on a spider class, so it is now ignored, with a warning, instead of raising TypeError. (#3119, #8094)

  • get_project_settings() now adds the project directory to sys.path also when the SCRAPY_SETTINGS_MODULE environment variable is set, so that the settings module that the variable points to can be imported. (#4780, #8042)

  • scrapy.utils.datatypes.LocalCache no longer evicts the oldest item when updating an existing one. (#8113)

Documentation

Quality assurance

Scrapy 2.18.0 (2026-08-20)

Highlights:

  • HttpxDownloadHandler now uses httpx2

  • The Twisted-based HTTP/2 download handler is no longer experimental

  • brotli and Zstandard support are now always available, and optional extras cover the rest of the optional features

  • Late Crawler attributes, such as stats, now raise RuntimeError instead of being None before the crawl starts

  • Item exporters now export fields in declaration order

  • New MetaCopyDetectionMiddleware

  • New optimization page and built-in stats reference

Modified requirements

  • brotli (brotlicffi on PyPy) and Zstandard support (the standard library compression.zstd module on Python 3.14 and higher, the backports.zstd package on earlier versions) are now required, so br and zstd are always included in the Accept-Encoding header of requests, and Brotli- and Zstandard-compressed responses are always decoded. Websites may now serve such responses to crawls that previously did not advertise support for them.

    The minimum required versions are brotli 1.2.0, brotlicffi 1.2.0.0 and backports.zstd 1.3.0.

    (#4698, #6978, #7083, #7929, #8009)

  • Increased the minimum versions of the following dependencies:

    (#7841, #7874, #7879, #8001)

  • The IPython shell requires IPython 8.15.0 or higher. Install the ipython extra to get a compatible version. (#5447, #7596, #7816)

Backward-incompatible changes

  • The following runtime usage of zope.interface interfaces is removed:

    • SpiderLoader and DummySpiderLoader are no longer marked as implementing the ISpiderLoader interface.

    • get_spider_loader() no longer checks that the configured spider loader implements the ISpiderLoader interface.

    • BlockingFeedStorage, FileFeedStorage and StdoutFeedStorage are no longer marked as implementing the IFeedStorage interface.

    • H2DownloadHandler no longer checks that the DOWNLOADER_CLIENTCONTEXTFACTORY class implements the IPolicyForHTTPS interface.

    (#6585, #7731)

  • The engine, extensions, logformatter, request_fingerprinter and stats attributes of Crawler raise RuntimeError when read before the crawl starts, instead of being None until then.

    Code that reads them from the spider_opened signal handler onwards is unaffected, and no longer needs to narrow their type. Code that checked whether they were set, e.g. if crawler.stats:, must be updated, since reading them now raises instead of returning None.

    (#6136, #7882)

  • Item exporters now export the fields of an item in declaration order, i.e. the order in which they are defined in the item class, instead of the order in which they were populated, as CsvItemExporter already did. dict items, which have no declared fields, keep using the key order of each item. (#6662, #6854, #7824)

  • scrapy.utils.serialize.ScrapyJSONEncoder, used by JSON feed exports, the telnet console and the PeriodicLog extension, now serializes datetime, date and time objects in ISO 8601 format, e.g. 2023-08-03T23:24:57.148903+00:00 instead of 2023-08-03 23:24:57, keeping microseconds and time zone information.

    Its DATE_FORMAT and TIME_FORMAT attributes are removed.

    (#2087, #7918)

  • scrapy.utils.trackref.live_refs is now a WeakKeyDictionary instead of a collections.defaultdict, so that classes defined at run time are released once they are no longer used. Reading the entry of a class with no tracked instances now raises KeyError instead of creating and returning an empty mapping. (#5995, #7922)

  • The MEMDEBUG_NOTIFY setting is removed. It had no effect, but code reading it now gets None instead of its default value, which was an empty list. (#7737)

  • scrapy.utils.log.logformatter_adapter() no longer passes the whole dict returned by a log formatter method as logging arguments when that dict has no args key, or its args are empty, and its msg has no %(name)s placeholders. Such messages are now logged verbatim, so a literal % in them no longer breaks logging.

    An args tuple is now expanded into one logging argument per item, so that %-style placeholders work with it as they do with a dict.

    (#5570, #5572, #7936)

  • FEEDS keys and FEED_URI values that are pathlib.Path objects are now used as paths, instead of being converted into file:// URIs. This makes them keep working when they contain URI parameters or characters that URI conversion would percent-encode. (#5794, #6425, #6611, #7674)

  • Selector and TextResponse.selector no longer force the html selector type for responses that are neither HtmlResponse nor XmlResponse objects. A JsonResponse gets the json type, and for any other response parsel determines the type from the body.

    The response class, and hence the selector type, comes from the content type that the website reports. When a website reports the wrong content type, recast the response, e.g. response.replace(cls=HtmlResponse).

    (#4627, #5291, #6025, #7924, #7972)

  • AutoThrottle no longer sets the download_delay attribute of the running spider to define the starting delay of download slots. The starting delay is still applied, but code that reads that attribute at run time no longer sees it. (#7167, #7175, #7833)

  • The check command now ignores ITEM_PIPELINES and FEEDS, since contracts check the output of callbacks instead of sending it to item processing, so a check run no longer triggers their side effects, e.g. writing an empty output file. Use the -s command-line option to set them back for a check run. (#3385, #7957)

  • XMLFeedSpider and CSVFeedSpider no longer raise NotConfigured when parse_node() or parse_row() is not defined; the resulting AttributeError is reported instead. (#7768)

Deprecation removals

  • scrapy.utils.misc.md5sum(), deprecated since Scrapy 2.12.0, is removed. (#6264, #8023)

  • scrapy.utils.iterators.xmliter(), deprecated since Scrapy 2.11.1 because it is vulnerable to ReDoS attacks, is removed. Use xmliter_lxml() instead. (#7765)

  • scrapy.utils.datatypes.CaselessDict, deprecated since Scrapy 2.10.0, is removed. Use CaseInsensitiveDict instead. (#5146, #8023)

Deprecations

  • The download_delay spider attribute is deprecated. Use the DOWNLOAD_DELAY setting, or DOWNLOAD_SLOTS to set a delay for specific domains, instead.

    The max_concurrent_requests spider attribute, deprecated since Scrapy 2.14.0, now sets the CONCURRENT_REQUESTS_PER_DOMAIN setting, which is what it always mapped to, and warns accordingly.

    Both attributes are ignored, with a different warning, when the corresponding setting is already set at the spider priority or higher.

    (#7167, #7175, #7833)

  • The Spider.log() method is deprecated. Use the methods of Spider.logger instead. (#7739)

  • The scrapy.interfaces module and its ISpiderLoader interface are deprecated. Custom spider loaders only need to follow SpiderLoaderProtocol. (#6585, #7731)

  • scrapy.extensions.feedexport.IFeedStorage is deprecated. Custom feed storages only need to follow scrapy.extensions.feedexport.FeedStorageProtocol. (#6585, #7731)

  • scrapy.utils.python.re_rsearch() is deprecated. (#7765)

  • Importing FileException from scrapy.pipelines.files is deprecated. Import it from scrapy.pipelines.media instead. (#7544, #7673, #7973)

  • Setting request.meta["is_secure"] to False to send an s3:// request over plaintext HTTP is deprecated. The flag will be ignored in a future Scrapy version. (#7738)

  • The unused multiplier attribute of PeriodicLog is deprecated. (#7809, #7982)

  • Returning, from a log formatter method, a msg with %(name)s placeholders and no args is deprecated. Those placeholders are still interpolated with the returned dict, but in a future Scrapy version the message will be logged verbatim. Return those values under args instead. (#5570, #7971)

New features

Bug fixes

  • HttpCacheMiddleware now logs a warning and handles the request as a cache miss when reading a cache entry raises an exception, e.g. because the entry is corrupted, instead of letting the exception propagate. It also counts those entries in the new httpcache/retrieve_error stat. (#2222, #7805)

  • Feed URIs now only expand %(...)s parameters, keeping any other percent character as is, so that percent-encoded URIs, e.g. one with %20 in a path or with percent-encoded FTP credentials, are no longer misinterpreted as printf-style formatting directives. (#5794, #6425, #7674)

  • Feed exports now start storing a FEED_EXPORT_BATCH_ITEM_COUNT batch as soon as it is complete, instead of waiting until the spider closes. (#7730, #7733)

  • CsvItemExporter now warns when the fields that it took from the first item do not cover the fields of a later item, i.e. when it silently drops data. (#4002, #4053, #7613, #7651)

  • GCSFeedStorage no longer requires the storage.buckets.get permission. (#5475, #7945)

  • Media pipelines now log media requests that were filtered out, e.g. as offsite requests, at the DEBUG level and without a traceback, instead of reporting them as download errors. (#7544, #7673)

  • OffsiteMiddleware now raises IgnoreRequest with a message, e.g. Filtered offsite request to 'offsite.example', which errbacks and log messages that report that exception now include. (#7544, #7673)

  • HTTP11DownloadHandler now skips response header lines that have no colon, logging them at the DEBUG level, as web browsers do, instead of being unable to download such a response at all. (#210, #7806)

  • CookiesMiddleware now sends domain cookies to hosts without a dot in their name and to hosts given as an IP address. (#6410, #7900)

  • TextResponse.json() now decodes bodies that are not valid UTF-8, UTF-16 or UTF-32 using TextResponse.encoding, instead of raising UnicodeDecodeError. (#6456, #7897)

  • scrapy.resolver.CachingHostnameResolver now caches addresses without a port, and sets the requested port on cache hits, so that a cached address no longer carries the port of the request that populated the cache. (#6442, #7772)

  • DownloaderAwarePriorityQueue now removes the directory of a download slot from the JOBDIR directory once that slot is drained. (#5275, #7955)

  • TelnetConsole no longer raises an exception on shutdown when it could not listen on any of the TELNETCONSOLE_PORT ports. (#2702, #7910)

  • The DOWNLOAD_WARNSIZE warning is no longer logged twice for a response whose Content-Length header already exceeded the limit. (#2476, #7963)

  • HttpCompressionMiddleware now logs a warning when it drops a response for exceeding DOWNLOAD_MAXSIZE during decompression. (#6616, #7742)

  • DepthMiddleware now logs only the first request ignored for exceeding DEPTH_LIMIT, and counts them all in the new depth/request_ignored_count stat. (#1308, #7916)

  • parse now sets the callback it uses on the request of the response it passes to that callback. (#3095, #3124, #7803)

  • The IPython shell now works when an asyncio event loop is already running in the same thread, e.g. when calling scrapy.shell.inspect_response() from a callback while using the asyncio reactor. (#5447, #7816)

  • Request.from_curl() now merges repeated -d, --data and --data-raw options into a single body joined with &, as curl does, instead of keeping only the last one. (#7728)

  • The copy() method and the |= operator of scrapy.utils.datatypes.CaseInsensitiveDict no longer leave the internal mapping of original key spellings shared or out of date. (#7783)

  • ExecutionEngine.download_async() no longer recurses once per returned request, e.g. once per redirect. (#7544, #7673)

  • LinkExtractor now canonicalizes each extracted URL once instead of twice when canonicalize is True. (#7961)

  • Items yielded from Spider.start() now keep the spider busy until the item pipelines are done with them, so that a spider that only yields items from start() no longer closes before processing them. (#7029, #7891)

  • open_in_browser() now also adds its base tag to HTML responses that have no head element, and it now overrides a base tag already present in the response, so that relative URLs resolve against the response URL in every case. (#6550, #7879)

  • Spider.start() implementations that are not asynchronous generators now raise TypeError with a message that says so, instead of failing in a way that does not point at the cause. (#5426, #7946)

  • The check, fetch and parse commands now return the exit code 1 when a component fails to initialize, as crawl and runspider already did. (#4292, #7920)

  • HttpCompressionMiddleware no longer hangs on a deflate response body followed by extra bytes. (#7841)

  • scrapy.utils.python.get_func_args() now reports the parameters that a functools.partial object binds by position, instead of an empty list. (#7841)

  • Fixed NameError exceptions on Python 3.14, where PEP 649 made annotation evaluation lazy, when inspecting the signature of a callable with annotations imported only for type checking. (#7796, #7818)

  • scrapy.utils.decorators.deprecated can now be used both as @deprecated and as @deprecated(...) without confusing type checkers. (#7797)

  • The default download handlers can now download from domains with emoji characters or underscores, which were previously rejected. (#3321, #4330, #7846)

  • Callbacks and media pipeline results no longer wait 100 ms before proceeding. (#8019)

  • Shutting down a crawl no longer risks raising an unhandled RuntimeError if the code interrupted by the shutdown signal was itself writing to the log. (#8022)

  • Nested selectors, e.g. the result of calling jmespath() on a selector, now let parsel determine their type instead of forcing the html type, so that they no longer return the wrong type or value. (#8038, #8040)

Documentation

Quality assurance

Scrapy 2.17.0 (2026-07-07)

Highlights:

  • Security bug fixes

  • HTTP/2 and SOCKS proxy support for HttpxDownloadHandler

  • Improved settings for changing allowed TLS versions

Security bug fixes

  • s3:// requests now use HTTPS by default, instead of plaintext HTTP.

    Previously, S3DownloadHandler sent signed S3 requests over plaintext HTTP unless request.meta["is_secure"] was set to a true value, exposing the request path, the AWS Authorization header, the X-Amz-Security-Token header (when using temporary credentials), and the response contents to network attackers, who could also tamper with responses. See the 76g3-c3x4-crvx security advisory for details.

    To restore the previous behavior for a given request, set request.meta["is_secure"] to False.

Deprecations

  • The DOWNLOADER_CLIENT_TLS_METHOD setting is deprecated. You should use the DOWNLOAD_TLS_MIN_VERSION and/or DOWNLOAD_TLS_MAX_VERSION settings instead if you want to change the TLS method selection. (#3288, #6546)

  • The following spider attributes are deprecated in favor of settings:

    (#7590)

  • The scrapy.commands.ScrapyCommand.help() method is deprecated. It was never called by Scrapy. (#7626, #7633)

  • The following TLS-related functions and constants, intended for internal use, are deprecated:

    • scrapy.core.downloader.tls.METHOD_TLS

    • scrapy.core.downloader.tls.METHOD_TLSv10

    • scrapy.core.downloader.tls.METHOD_TLSv11

    • scrapy.core.downloader.tls.METHOD_TLSv12

    • scrapy.core.downloader.tls.openssl_methods

    • scrapy.core.downloader.tls.DEFAULT_CIPHERS

    • scrapy.utils.ssl.ffi_buf_to_string()

    • scrapy.utils.ssl.get_temp_key_info()

    • scrapy.utils.ssl.x509name_to_string()

    (#6546, #7619, #7665)

  • The CRAWLSPIDER_FOLLOW_LINKS setting is deprecated. You can set follow=False in your rules to achieve the same effect. (#7592)

  • Instantiating HttpCompressionMiddleware without a crawler argument is deprecated. (#7655)

  • Instantiating RefererMiddleware without a settings argument is deprecated. (#7664)

New features

Improvements

  • FormRequest is no longer deprecated, only its from_response() method is still deprecated. (#7561, #7671)

  • Switched the item definition in the default project template from a scrapy.item.Item to a dataclass. (#7493, #7513)

  • Fixed deprecation warnings with pyOpenSSL 26.3.0. (#7619)

  • Removed the runtime warnings for Spider.allowed_domains containing URLs or domains with ports instead of just domains and for spider classes having a start_url attribute instead of start_urls. Please use scrapy-lint to find mistakes in your spider code instead. (#4421, #7627)

  • scrapy.utils.test.get_crawler() now disables TELNETCONSOLE_ENABLED by default. (#7644)

  • Other code refactoring and improvements. (#7409, #7593, #7594, #7611, #7649)

Bug fixes

  • HttpxDownloadHandler no longer ignores proxy credentials for redirected or retried requests. (#7601, #7630)

  • GCSFeedStorage now closes the temporary file after the upload. (#7546)

  • Fixed scrapy shell <URL> running a full spider crawl when there is a spider for the requested URL. This bug was introduced in Scrapy 2.13.0. (#7552, #7557)

  • The IMAGES_STORE_S3_ACL and IMAGES_STORE_GCS_ACL settings are no longer ignored. This bug was introduced in Scrapy 2.12.0. (#7597, #7614)

  • FTPDownloadHandler now closes the connection after making the request. (#7602, #7667)

  • Removed the deprecated spider argument from the pipeline defined in the default project template. (#7676)

  • Fixed scrapy genspider --edit not working. (#7260, #7683)

  • When a Crawler instance is passed to AsyncCrawlerRunner.create_crawler() or CrawlerRunner.create_crawler(), settings from both classes are now merged, previously only the settings from the Crawler instance were used. (#1280, #7647)

  • Fixed several issues with cookie handling in scrapy.utils.request.request_to_curl(). (#7603, #7675, #7684)

  • Fixed scrapy.resolver.CachingThreadedResolver not disabling the cache when DNSCACHE_ENABLED is set to False. (#7663)

  • Fixed scrapy.utils.response.open_in_browser() not removing comments when looking for the <base> tag. (#7506)

  • Fixed checking for deprecated methods in custom ITEM_PROCESSOR implementations. (#7589)

  • Fixed scrapy.utils.url.strip_url() corrupting some URLs with credentials. (#7604, #7605)

  • scrapy.utils.misc.rel_has_nofollow() now ignores the case when looking for “nofollow” strings. (#7632)

  • Fixed an exception in scrapy.utils.sitemap.Sitemap when parsing some malformed sitemaps. (#7686, #7687)

Documentation

Quality assurance

Scrapy 2.16.0 (2026-05-19)

Highlights:

  • Official support for Python 3.14

  • Support for Twisted 26.4.0+

Modified requirements

Backward-incompatible changes

  • The following classes and functions, intended for internal use by HTTP11DownloadHandler and H2DownloadHandler, have been made private:

    • scrapy.core.downloader.handlers.http11.ScrapyAgent

    • scrapy.core.downloader.handlers.http11.ScrapyProxyAgent

    • scrapy.core.downloader.handlers.http11.TunnelingAgent

    • scrapy.core.downloader.handlers.http11.TunnelingTCP4ClientEndpoint

    • scrapy.core.downloader.handlers.http11.tunnel_request_data()

    • scrapy.core.downloader.handlers.http2.ScrapyH2Agent

    (#7496, #7510)

Deprecations

Deprecation removals

  • The start_requests() method of Spider, deprecated in 2.13.0, is removed and no longer called. Use start() instead, or both to maintain support for lower Scrapy versions. (#7490)

  • Support for process_start_requests() methods of spider middlewares, deprecated in 2.13.0, is removed. Use process_start() instead, or both to maintain support for lower Scrapy versions. (#7490)

  • Support for synchronous process_spider_output() methods of spider middlewares, deprecated in Scrapy 2.13.0, is removed. You should upgrade the affected middlewares to have asynchronous process_spider_output() methods. (#7504)

  • The spider arguments of the following methods of Scraper, deprecated in Scrapy 2.13.0, are removed:

    • close_spider()

    • enqueue_scrape()

    • handle_spider_error()

    • handle_spider_output()

    (#7487)

  • HTTP/1.0 support code, deprecated in Scrapy 2.13.0, is removed. This includes:

    • scrapy.core.downloader.handlers.http10.HTTP10DownloadHandler

    • The scrapy.core.downloader.webclient module.

    • The DOWNLOADER_HTTPCLIENTFACTORY setting.

    (#7486)

  • The following functions, deprecated in Scrapy 2.13.0, are removed, you should import them from w3lib.url directly instead:

    • scrapy.utils.url.add_or_replace_parameter()

    • scrapy.utils.url.add_or_replace_parameters()

    • scrapy.utils.url.any_to_uri()

    • scrapy.utils.url.canonicalize_url()

    • scrapy.utils.url.file_uri_to_path()

    • scrapy.utils.url.is_url()

    • scrapy.utils.url.parse_data_uri()

    • scrapy.utils.url.parse_url()

    • scrapy.utils.url.path_to_file_uri()

    • scrapy.utils.url.safe_download_url()

    • scrapy.utils.url.safe_url_string()

    • scrapy.utils.url.url_query_cleaner()

    • scrapy.utils.url.url_query_parameter()

    (#7487)

  • The following test-related code, deprecated in Scrapy 2.13.0, is removed:

    • the scrapy.utils.testproc module

    • the scrapy.utils.testsite module

    • scrapy.utils.test.assert_gcs_environ()

    • scrapy.utils.test.get_ftp_content_and_delete()

    • scrapy.utils.test.get_gcs_content_and_delete()

    • scrapy.utils.test.mock_google_cloud_storage()

    • scrapy.utils.test.skip_if_no_boto()

    • scrapy.utils.test.TestSpider

    (#7487)

  • scrapy.utils.versions.scrapy_components_versions(), deprecated in Scrapy 2.13.0, is removed, you can use scrapy.utils.versions.get_versions() instead. (#7487)

  • scrapy.downloadermiddlewares.ajaxcrawl.AjaxCrawlMiddleware and scrapy.utils.url.escape_ajax(), deprecated in Scrapy 2.13.0, are removed. (#7487)

  • The __init__() method of priority queue classes (see SCHEDULER_PRIORITY_QUEUE) now needs to support a keyword-only start_queue_cls parameter, not supporting it was deprecated in Scrapy 2.13.0. (#7487)

  • scrapy.spiders.init.InitSpider, deprecated in Scrapy 2.13.0, is removed. (#7487)

New features

  • New features and improvements for HttpxDownloadHandler:

    • Support for proxies.

    • Support for the download_latency meta key.

    • Support for Response.certificate.

    • Default headers set by the httpx library are no longer added to requests.

    (#7441, #7524)

  • HTTP11DownloadHandler now skips HTTPS proxy certificate verification when the DOWNLOAD_VERIFY_CERTIFICATES setting is set to False. (#7496)

Improvements

  • time.monotonic() is used instead of time.time() to calculate elapsed time in various places. (#7377)

  • Improved extraction of the file extension from the URL in FilesPipeline. (#4225, #7414)

  • Other code refactoring and improvements. (#7401)

Bug fixes

  • HTTP11DownloadHandler now raises an exception when a request has an https:// destination and an https:// proxy, which is not supported by this handler. Previously it tried to connect to the proxy via HTTP in this case. (#7496)

  • H2DownloadHandler now raises an exception for requests with http:// URLs instead of trying to connect, which is not supported by this handler. (#7496)

  • H2DownloadHandler no longer adds the :status pseudo-header to Response.headers. (#7441)

  • Fixed scrapy.utils.response.open_in_browser() removing the <head> tag when adding the <base> tag. (#7459)

Documentation

  • Documented that HTTP11DownloadHandler doesn’t support HTTPS proxies for HTTPS destinations and that H2DownloadHandler doesn’t support proxies at all. (#7496)

  • Added an example of using logging.handlers.TimedRotatingFileHandler to rotate Scrapy logs. (#3628, #7501)

  • Added a CITATION.cff file. (#7502, #7519)

  • Mentioned DOWNLOADER_CLIENT_TLS_METHOD in Avoiding getting banned. (#5232, #7518)

  • Other documentation improvements and fixes. (#7417, #7463, #7472, #7480, #7489, #7503, #7507)

Quality assurance

  • Added tests that connect to https://books.toscrape.com/ to test the behavior with a real website. These tests are marked with the requires_internet pytest mark and can be skipped with e.g. -m 'not requires_internet' if you cannot or don’t want to run them. (#7520)

  • Type hints improvements and fixes. (#7492, #7532)

  • CI and test improvements and fixes. (#7441, #7466, #7491, #7496)

Scrapy 2.15.2 (2026-04-28)

Bug fixes

Scrapy 2.15.1 (2026-04-23)

Bug fixes

  • Sharing of the SSL context between multiple connections, introduced in Scrapy 2.15.0, is reverted as it caused problems and wasn’t actually needed. (#7445, #7450)

  • Fixed scrapy.settings.BaseSettings.getwithbase() failing on keys with dots that aren’t import names. It now works the way it worked before Scrapy 2.15.0, without trying to match class objects and import path. A separate method, get_component_priority_dict_with_base(), was added that does that, and it is now used for component priority dictionaries. (#7426, #7449)

  • Documentation rendering improvements. (#7452, #7454)

Scrapy 2.15.0 (2026-04-09)

Highlights:

  • Experimental support for running without a Twisted reactor

  • Experimental httpx-based download handler

Backward-incompatible changes

  • The built-in HTTP download handlers now raise Scrapy-specific exceptions instead of implementation-specific ones, see Exceptions raised by download handlers. This can affect user code that handles downloader exceptions, such as process_exception() methods of custom downloader middlewares. (#7208)

  • In order to fix a long-standing bug with handling of asynchronous storages, the following changes were made to media pipeline classes, which can impact some of the user code that subclasses them or calls their methods directly:

    • overrides of scrapy.pipelines.media.MediaPipeline.media_downloaded() and file_downloaded() can now return coroutines

    • media_downloaded(), file_downloaded() and image_downloaded() now return coroutines

    (#2183, #6369, #7182)

  • Request and Response objects: __slots__ and setter changes:

    • scrapy.http.Request and scrapy.http.Response now define __slots__. Assigning arbitrary attributes to instances (for example, response.foo = 1) will raise AttributeError. Store per-request/response data in the request/response meta mapping instead of attaching new attributes to the objects.

    • If you maintain custom Request or Response subclasses that relied on dynamic instance attributes, either add '__dict__' to your subclass __slots__ to allow dynamic attributes, or migrate per-instance state to meta or explicit documented attributes.

    • The setters for headers, flags and cookies no longer coerce falsy values into None. For example, request.headers = {} now stores an empty scrapy.http.headers.Headers instance (not None), and request.flags = [] remains an empty list instead of being set to None. Update code that relied on is None checks or the previous coercion behaviour.

    (#7036, #7367, #7374)

Deprecation removals

  • The context factory class set as the value of the DOWNLOADER_CLIENTCONTEXTFACTORY setting is now required to support the method argument of __init__(), recommended since Scrapy 1.2.0. (#7353)

Deprecations

  • scrapy.mail.MailSender is deprecated. Please use smtplib, twisted.mail.smtp or other 3rd party email libraries. (#7249, #7263)

  • The scrapy.extensions.statsmailer.StatsMailer extension is deprecated. You can instead implement your own notifications by handling the spider_closed signal. (#7249, #7263)

  • The MEMUSAGE_NOTIFY_MAIL setting is deprecated. You can instead implement your own notifications by handling the memusage_warning_reached and spider_closed signals. (#7249, #7263)

  • The DNS_RESOLVER setting was renamed to TWISTED_DNS_RESOLVER and the old name is deprecated. (#7350, #7361)

  • The DOWNLOADER_CLIENTCONTEXTFACTORY setting is deprecated. If you were using it to switch to scrapy.core.downloader.contextfactory.BrowserLikeContextFactory, please use the new DOWNLOAD_VERIFY_CERTIFICATES setting instead. If you cannot use the default context factory for some other reason, please subclass the download handler instead. (#7352, #7379)

  • scrapy.core.downloader.contextfactory.BrowserLikeContextFactory is deprecated. You can set the new DOWNLOAD_VERIFY_CERTIFICATES setting to True instead. (#7379)

  • The following implementation details of the context factory handling code are deprecated:

    • scrapy.core.downloader.contextfactory.AcceptableProtocolsContextFactory

    • scrapy.core.downloader.contextfactory.load_context_factory_from_settings()

    • scrapy.core.downloader.contextfactory.ScrapyClientContextFactory

    • scrapy.core.downloader.tls.ScrapyClientTLSOptions

    (#7353, #7391)

  • Passing str instead of bytes to scrapy.utils.sitemap.Sitemap and scrapy.utils.sitemap.sitemap_urls_from_robots() is deprecated. (#7007)

  • scrapy.utils.misc.walk_modules() is deprecated. You can use scrapy.utils.misc.walk_modules_iter() instead. (#7388)

  • scrapy.shell.Shell.inthread is deprecated. You can use scrapy.shell.Shell.fetch_available instead to check if fetch() can be used. (#7395)

  • scrapy.commands.ScrapyCommand.set_crawler() is deprecated. (#7276)

New features

Improvements

  • asyncio.to_thread() is now used instead of twisted.internet.threads.deferToThread() in the built-in feed storages, media pipeline storages and the scrapy.utils.decorators.inthread() decorator when available. (#7183, #7184, #7349)

  • Improved memory footprint of Request and Response objects by adding __slots__ and omitting empty lists and dicts in some internal attributes. (#7036, #7367, #7374)

  • _ScrapyClientContextFactory no longer mutates the SSL context, to avoid the behavior that was deprecated in pyOpenSSL 25.1.0. (#6859, #7353)

  • Improved memory usage of SitemapSpider and scrapy.utils.sitemap.Sitemap. (#3529, #7007)

  • Improved the scheduling behavior of DownloaderAwarePriorityQueue when crawling multiple domains. (#7293, #7351)

  • HTTP11DownloadHandler and H2DownloadHandler now handle TLS verbose logging (see DOWNLOADER_CLIENT_TLS_VERBOSE_LOGGING) directly instead of relying on _ScrapyClientContextFactory. (#7387)

  • The server certificate verification code now correctly handles certificates with IP addresses in subjectAltName. (#7353)

  • Improved reliability of scrapy.utils.trackref.get_oldest(). (#1758, #7375)

  • Other code refactoring and improvements. (#7210, #7238, #7376, #7386, #7395, #7405, #7410)

Bug fixes

  • Media pipelines should now wait for uploads to asynchronous storages (e.g. S3FilesStore) to complete. (#2183, #6369, #7182)

  • Fixed merging *_BASE settings (e.g. merging DOWNLOADER_MIDDLEWARES with DOWNLOADER_MIDDLEWARES_BASE) when a component is referred to by a class object in one setting and by a string import path in the other one. (#6912, #6993)

  • scrapy runspider and scrapy crawl now set the exit code to 1 if an exception happened early (this was broken since Scrapy 2.13.0). (#6820, #7255)

  • Fixed repeated warnings about data loss (see DOWNLOAD_FAIL_ON_DATALOSS) not being suppressed in HTTP11DownloadHandler. (#7222)

  • Improved FTP connection management in scrapy.pipelines.files.FTPFilesStore. (#7256)

  • Fixed the spider variable in the shell, which wasn’t available since Scrapy 2.13.0. (#7395)

Documentation

Quality assurance

Scrapy 2.14.2 (2026-03-12)

Security bug fixes

  • Values from the Referrer-Policy header of HTTP responses are no longer executed as Python callables. See the cwxj-rr6w-m6w7 security advisory for details.

  • In line with the standard, 301 redirects of POST requests are converted into GET requests.

    Converting to a GET request implies not only a method change, but also omitting the body and Content-* headers in the redirect request. On cross-origin redirects (for example, cross-domain redirects), this is effectively a security bug fix for scenarios where the body contains secrets.

Deprecations

  • Passing a response URL string as the first positional argument to scrapy.spidermiddlewares.referer.RefererMiddleware.policy() is deprecated. Pass a Response instead.

    The parameter has also been renamed to response to reflect this change. The old parameter name (resp_or_url) is deprecated.

New features

  • Added a new setting, REFERRER_POLICIES, to allow customizing supported referrer policies.

Bug fixes

  • Made additional redirect scenarios convert to GET in line with the standard:

    • Only POST 302 redirects are converted into GET requests; other methods are preserved.

    • HEAD 303 redirects are not converted into GET requests.

    • GET 303 redirects do not have their body or standard Content-* headers removed.

  • Redirects where the original request body is dropped now also have their Content-Encoding, Content-Language and Content-Location headers removed, in addition to the Content-Type and Content-Length headers that were already being removed.

  • Redirects now preserve the source URL fragment if the redirect URL does not include one. This is useful when using browser-based download handlers, such as scrapy-playwright or scrapy-zyte-api, while letting Scrapy handle redirects.

  • The Referer header is now removed on redirect if RefererMiddleware is disabled.

  • The handling of the Referer header on redirects now takes into account the Referer-Policy header of the response that triggers the redirect.

Scrapy 2.14.1 (2026-01-12)

Deprecations

  • scrapy.utils.defer.maybeDeferred_coro() is deprecated. (#7212)

Bug fixes

  • Fixed custom stats collectors that require a spider argument in their open_spider() and close_spider() methods not receiving the argument when called by the engine.

    Note, however, that the spider argument is now deprecated and will stop being passed in a future version of Scrapy.

    (#7213)

Quality assurance

  • Replaced deprecated codecov/test-results-action@v1 GitHub Action with codecov/codecov-action@v5. (#7180, #7215)

Scrapy 2.14.0 (2026-01-05)

Highlights:

  • More coroutine-based replacements for Deferred-based APIs

  • The default priority queue is now DownloaderAwarePriorityQueue

  • Dropped support for Python 3.9 and PyPy 3.10

  • Improved and documented the API for custom download handlers

Modified requirements

  • Dropped support for Python 3.9. (#7121)

  • Dropped support for PyPy 3.10. (#7050)

  • Increased the minimum versions of the following dependencies:

    • lxml: 4.6.0 → 4.6.4

    • Pillow (optional dependency): 8.0.0 → 8.3.2

    • botocore (optional dependency): 1.4.87 → 1.13.45

  • Restored support for brotlicffi dropped in Scrapy 2.13.4. Its minimum supported version is now 1.2.0.0. (#7160)

Backward-incompatible changes

  • If you set the TWISTED_REACTOR setting to a non-asyncio value at the spider level, you may now need to set the FORCE_CRAWLER_PROCESS setting to True when running Scrapy via its command-line tool to avoid a reactor mismatch exception. (#6845)

  • The log_count/* stats no longer count some of the early messages that they counted before. While the earliest log messages, emitted before the counter is initialized, were never counted, the counter initialization now happens later than in previous Scrapy versions. You may need to adjust expected values if you retrieve and compare values of these stats in your code. (#7046)

  • The classes listed below are now abstract base classes. They cannot be instantiated directly and their subclasses need to override the abstract methods listed below to be able to be instantiated. If you previously instantiated these classes directly, you will now need to subclass them and provide trivial (e.g. empty) implementations for the abstract methods.

    • scrapy.commands.ScrapyCommand

      • run()

      • short_desc()

    • scrapy.exporters.BaseItemExporter

      • export_item()

    • scrapy.extensions.feedexport.BlockingFeedStorage

      • _store_in_thread()

    • scrapy.middleware.MiddlewareManager

      • _get_mwlist_from_settings()

    • scrapy.spidermiddlewares.referer.ReferrerPolicy

      • referrer()

    (#6930)

  • Scrapy no longer passes a spider argument to any methods of the stats collector. It wasn’t passed in many of the calls even in older Scrapy versions, so we don’t expect existing custom stats collector implementations to require a spider argument. If your implementation needs a Spider instance, you can get it from the Crawler instance passed to the constructor. (#7011)

  • scrapy.middleware.MiddlewareManager no longer includes code for handling open_spider() and close_spider() component methods. As this code was only used for pipelines it was moved into scrapy.pipelines.ItemPipelineManager. This change should only affect custom subclasses of MiddlewareManager. The following code was moved:

    • scrapy.middleware.MiddlewareManager.open_spider()

    • scrapy.middleware.MiddlewareManager.close_spider()

    • Code in scrapy.middleware.MiddlewareManager._add_middleware() that processes open_spider() and close_spider() component methods.

    (#7006)

  • scrapy.downloadermiddlewares.robotstxt.RobotsTxtMiddleware.process_request() now returns a coroutine, previously it returned a Deferred object or None. The robot_parser() method was also changed to return a coroutine. This change only impacts code that subclasses RobotsTxtMiddleware or calls its methods directly. (#6802)

  • The built-in download handlers have been refactored, changing the signatures of their methods. This change should only affect user code that subclasses any of these handlers or calls their methods directly. (#6778, #7164)

  • scrapy.pipelines.media.MediaPipeline.process_item() now returns a coroutine, previously it returned a Deferred object. This change only impacts code that calls this method directly. (#7177)

Deprecation removals

  • The from_settings() method of the following components, deprecated in Scrapy 2.12.0, is removed. You should use from_crawler() instead.

    (#7126)

  • Scrapy no longer calls from_settings() methods of 3rd-party components, deprecated in Scrapy 2.12.0. You should define a from_crawler() method instead. (#7126)

  • The initialization flow of scrapy.pipelines.media.MediaPipeline and its subclasses was simplified, it now mandates from_crawler() methods and crawler arguments of __init__() methods. Not using these was deprecated in Scrapy 2.12.0. (#7126)

  • The REQUEST_FINGERPRINTER_IMPLEMENTATION setting, deprecated in Scrapy 2.12.0, is removed. (#7126)

  • The scrapy.utils.misc.create_instance() function, deprecated in Scrapy 2.12.0, is removed. Use scrapy.utils.misc.build_from_crawler() instead. (#7126)

  • The scrapy.core.downloader.Downloader._get_slot_key() function, deprecated in Scrapy 2.12.0, is removed. Use scrapy.core.downloader.Downloader.get_slot_key() instead. (#7126)

  • The scrapy.twisted_version attribute, deprecated in Scrapy 2.12.0, is removed. You should instead use the twisted.version attribute directly. (#7126)

  • The following utility functions, deprecated in Scrapy 2.12.0, are removed:

    • scrapy.utils.defer.process_chain_both()

    • scrapy.utils.python.equal_attributes()

    • scrapy.utils.python.flatten()

    • scrapy.utils.python.iflatten()

    • scrapy.utils.request.request_authenticate()

    • scrapy.utils.test.assert_samelines()

    (#7126)

  • scrapy.utils.serialize.ScrapyJSONDecoder, deprecated in Scrapy 2.12.0, is removed. (#7126)

  • The scrapy.extensions.feedexport.build_storage() function, deprecated in Scrapy 2.12.0, is removed, you can instead call the builder callable directly. (#7126)

  • scrapy.spidermiddlewares.offsite.OffsiteMiddleware, deprecated in Scrapy 2.11.2, is removed. scrapy.downloadermiddlewares.offsite.OffsiteMiddleware should be used instead. (#6926)

Deprecations

  • The following methods that return a Deferred are deprecated in favor of their coroutine-based replacements:

    • scrapy.core.downloader.handlers.DownloadHandlers

      • download_request() (use download_request_async())

    • scrapy.core.downloader.middleware.DownloaderMiddlewareManager

      • download() (use download_async())

    • scrapy.core.engine.ExecutionEngine

      • start() (use start_async())

      • stop() (use stop_async())

      • close() (use close_async())

      • open_spider() (use open_spider_async())

      • close_spider() (use close_spider_async())

      • download() (use download_async())

    • scrapy.core.scraper.Scraper

      • open_spider() (use open_spider_async())

      • call_spider() (use call_spider_async())

      • close_spider() (use close_spider_async())

      • handle_spider_output() (use handle_spider_output_async())

      • start_itemproc() (use start_itemproc_async())

    • scrapy.core.spidermw.SpiderMiddlewareManager

      • scrape_response() (use scrape_response_async())

    • scrapy.crawler.Crawler

      • stop() (use stop_async())

    • scrapy.pipelines.ItemPipelineManager

      • process_item() (use process_item_async())

      • open_spider() (use open_spider_async())

      • close_spider() (use close_spider_async())

    • scrapy.signalmanager.SignalManager

      • send_catch_log_deferred() (use send_catch_log_async())

    • scrapy.utils.signal.send_catch_log_deferred() (use scrapy.utils.signal.send_catch_log_async())

    (#6791, #6842, #6979, #6997, #6999, #7005, #7043, #7069, #7161, #7164)

  • The following spider attributes are deprecated in favor of settings:

    (#6988, #6994, #7038, #7039, #7117, #7176)

  • Returning a Deferred from the following user-defined functions is deprecated in favor of defining them as coroutine functions:

    • spider callbacks and errbacks (which was never officially supported and may work incorrectly)

    • the process_request(), process_response() and process_exception() methods of custom downloader middlewares

    • the process_item(), open_spider() and close_spider() methods of custom pipelines

    • signal handlers

    • the download_request() and close() methods of custom download handlers

    (#6718, #6778, #7069, #7147, #7148, #7149, #7150, #7151, #7161, #7164, #7179)

  • Passing a spider argument to the following methods is deprecated:

    • scrapy.core.spidermw.SpiderMiddlewareManager.process_start()

    • scrapy.core.downloader.Downloader.fetch()

    • scrapy.core.downloader.Downloader._get_slot()

    • scrapy.core.downloader.handlers.DownloadHandlers.download_request()

    • all public methods of scrapy.statscollectors.StatsCollector

    • scrapy.spidermiddlewares.base.BaseSpiderMiddleware.process_spider_output()

    • scrapy.spidermiddlewares.base.BaseSpiderMiddleware.process_spider_output_async()

    • all process_*() methods of built-in downloader middlewares

    • all process_*() methods of built-in spider middlewares

    • scrapy.pipelines.media.MediaPipeline.open_spider()

    • scrapy.pipelines.media.MediaPipeline.process_item()

    (#6750, #6927, #6984, #7006, #7011, #7033, #7037, #7045, #7178)

  • Instantiating subclasses of scrapy.middleware.MiddlewareManager without a Crawler instance is deprecated. (#6984)

  • For the following user-defined functions and methods requiring a spider argument is deprecated, if you need a Spider instance inside them you should get it from the Crawler instance (you may need to refactor your code to save that instance in e.g. the from_crawler() method):

    • the process_request(), process_response() and process_exception() methods of custom downloader middlewares

    • the process_spider_input(), process_spider_output(), process_spider_output_async() and process_spider_exception() methods of custom spider middlewares

    • the process_item() method of custom pipelines

    • the fetch() method of a custom DOWNLOADER

    (#6927, #6984, #7006, #7037)

  • The following things in custom download handlers are deprecated:

    • not having a lazy attribute (you should define it as True if you want to keep the current behavior)

    • returning a Deferred from the download_request() method (you should refactor it to return a coroutine; you also need to remove the spider argument when doing this)

    • not having a close() method, having a synchronous one or one that returns a Deferred (you should refactor it to return a coroutine or add an empty one if you don’t have it)

    (#6778, #7164)

  • Custom implementations of ITEM_PROCESSOR should now define process_item_async(), open_spider_async() and close_spider_async() methods instead of, or in addition to, process_item(), open_spider() and close_spider(). (#7005, #7043)

  • The CONCURRENT_REQUESTS_PER_IP setting is deprecated, use CONCURRENT_REQUESTS_PER_DOMAIN instead. (#6917, #6921)

  • The scrapy.core.downloader.handlers.http module is deprecated. You should import scrapy.core.downloader.handlers.http11.HTTP11DownloadHandler directly instead of importing the scrapy.core.downloader.handlers.http.HTTPDownloadHandler alias. (#7079)

  • The scrapy.utils.decorators.defers() decorator is deprecated, you can use twisted.internet.defer.maybeDeferred() directly or reimplement this decorator in your code. (#7164)

  • scrapy.spiders.CrawlSpider._parse_response() is deprecated, use scrapy.spiders.CrawlSpider.parse_with_rules() instead. (#4463, #6804)

  • The functions that add a delay to a Deferred are deprecated, their underlying Twisted functions can be used instead, either directly if a delay isn’t needed, or with some explicit way to add a delay if it’s needed:

    • scrapy.utils.defer.mustbe_deferred() (you can use twisted.internet.defer.maybeDeferred())

    • scrapy.utils.defer.defer_succeed() (you can use twisted.internet.defer.succeed())

    • scrapy.utils.defer.defer_fail() (you can use twisted.internet.defer.fail())

    • scrapy.utils.defer.defer_result() (you can use twisted.internet.defer.succeed() and twisted.internet.defer.fail())

    (#6937)

New features

  • Added scrapy.crawler.AsyncCrawlerProcess and scrapy.crawler.AsyncCrawlerRunner as counterparts to CrawlerProcess and CrawlerRunner that offer coroutine-based APIs. (#6789, #6790, #6796, #6817, #6845, #7034)

  • Added coroutine counterparts to some of the Deferred-based APIs:

    • scrapy.core.downloader.handlers.DownloadHandlers

      • download_request_async() (to download_request())

    • scrapy.core.downloader.middleware.DownloaderMiddlewareManager

      • download_async() (to download())

    • scrapy.core.engine.ExecutionEngine

      • start_async() (to start())

      • stop_async() (to stop())

      • close_async() (to close())

      • open_spider_async() (to open_spider())

      • close_spider_async() (to close_spider())

      • download_async() (to download())

    • scrapy.core.scraper.Scraper

      • open_spider_async() (to open_spider())

      • close_spider_async() (to close_spider())

      • start_itemproc_async() (to start_itemproc())

    • scrapy.crawler.Crawler

      • crawl_async() (to crawl())

      • stop_async() (to stop())

    • scrapy.pipelines.ItemPipelineManager

      • process_item_async() (to process_item())

      • open_spider_async() (to open_spider())

      • close_spider_async() (to close_spider())

    • scrapy.signalmanager.SignalManager

      • send_catch_log_async() (to send_catch_log_deferred())

    (#6781, #6791, #6792, #6795, #6801, #6817, #6842, #6997, #7005, #7043, #7069,:gh:7164, #7202)

  • The default value of the SCHEDULER_PRIORITY_QUEUE setting is now 'scrapy.pqueues.DownloaderAwarePriorityQueue'. (#6924, #6940)

  • Added scrapy.extensions.logcount.LogCount, an enabled-by-default extension that is responsible for the log_count/* stats. Previously, this code was in scrapy.crawler.Crawler and couldn’t be disabled. (#7046)

  • Added scrapy.spiders.CrawlSpider.parse_with_rules() as a public replacement for _parse_response(). (#4463, #6804)

  • Added scrapy.utils.asyncio.is_asyncio_available() as an alternative to scrapy.utils.reactor.is_asyncio_reactor_installed with a future-proof name and semantics. (#6827)

  • The API for download handlers, previously undocumented, has been modernized and documented. An optional base class, scrapy.core.downloader.handlers.base.BaseDownloadHandler, has been added to simplify writing custom download handlers that conform to the current API. (#4944, #6778, #7164)

  • Added scrapy.utils.defer.ensure_awaitable(), which can be helpful to call user-defined functions that can return coroutines, Deferreds or values directly. (#7005)

  • The requests.seen file, written by RFPDupeFilter when job persistence is enabled, now uses line buffering to reduce data loss in spider crashes. (#6019, #7094)

  • Images downloaded by ImagesPipeline are now automatically transposed based on EXIF data. (#6525, #6975)

Improvements

  • Refactored internal functions to use coroutines instead of Deferreds. (#6795, #6852, #6855, #6858, #7159)

  • Commands that don’t need a CrawlerProcess instance no longer create it. (#6824)

  • Improved shell help formatting when using IPython 9+. (#6915, #6980)

Bug fixes

Documentation

Quality assurance

Older releases