# 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](https://github.com/scrapy/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](https://github.com/advisories/GHSA-h7wm-ph43-c39p).

  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](topics/media-pipeline.md), 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`](topics/settings.md) setting replaces
  `SCRAPER_SLOT_MAX_ACTIVE_SIZE` and covers all responses in memory,
  including those to [awaited requests](topics/coroutines.md "Inline requests") and to
  requests sent with [`ExecutionEngine.download_async()`](topics/api.md). Use it to change or
  disable the limit. The [`shell`](topics/commands.md) disables it.

  ([#482](https://github.com/scrapy/scrapy/issues/482), [#4583](https://github.com/scrapy/scrapy/issues/4583), [#6430](https://github.com/scrapy/scrapy/issues/6430), [#8417](https://github.com/scrapy/scrapy/issues/8417), [#8459](https://github.com/scrapy/scrapy/issues/8459), [#8460](https://github.com/scrapy/scrapy/issues/8460))
- [`HttpCompressionMiddleware`](topics/downloader-middleware.md)
  now decodes at most 1 content coding per response by default, and drops
  responses that apply more with [`IgnoreRequest`](topics/exceptions.md).

  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](https://github.com/scrapy/scrapy/security/advisories/GHSA-j72p-v7rm-cwm3) security advisory for details.

  To allow more content codings per response, set the new
  [`COMPRESSION_MAX_ENCODINGS`](topics/downloader-middleware.md) setting.
- When [`http_auth_domain`](topics/request-response.md) is not set, the credentials from
  [`http_user`](topics/request-response.md) and [`http_pass`](topics/request-response.md) 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`](topics/downloader-middleware.md) added
  them again to the `Authorization` header that
  [`RedirectMiddleware`](topics/downloader-middleware.md) 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](https://github.com/scrapy/scrapy/security/advisories/GHSA-466x-p45j-m4fx) security advisory for details.

  ([#8329](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/security/advisories/GHSA-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`](topics/settings.md),
  `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`](topics/settings.md) 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`](topics/media-pipeline.md) and
  [`ImagesPipeline`](topics/media-pipeline.md), 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](https://github.com/scrapy/scrapy/security/advisories/GHSA-fwm7-29m4-rrj9) security advisory for
  details.

  To restore the previous behavior, set [`AWS_USE_SSL`](topics/settings.md) to `False`.
- [`LxmlLinkExtractor`](topics/link-extractors.md) and
  [`SitemapSpider`](topics/spiders.md) 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`](topics/spiders.md) followed URLs
  of any scheme. A crawled website could use that to make Scrapy read local
  files, send the [`FTP_USER`](topics/settings.md) and [`FTP_PASSWORD`](topics/settings.md) credentials
  to an FTP server of its choosing, or send requests signed with the
  [`AWS_ACCESS_KEY_ID`](topics/settings.md) credentials to an S3 bucket of its choosing.
  See the [q7wc-mr9r-gcjh](https://github.com/scrapy/scrapy/security/advisories/GHSA-q7wc-mr9r-gcjh) security advisory for details.

  To follow URLs with other schemes, use the new `schemes` parameter of
  [`LxmlLinkExtractor`](topics/link-extractors.md) or the new
  [`sitemap_schemes`](topics/spiders.md) attribute of
  [`SitemapSpider`](topics/spiders.md).

### Modified requirements

- Dropped support for Python 3.10.
  ([#8261](https://github.com/scrapy/scrapy/issues/8261))
- Dropped support for PyPy.
  ([#7849](https://github.com/scrapy/scrapy/issues/7849), [#8358](https://github.com/scrapy/scrapy/issues/8358), [#8367](https://github.com/scrapy/scrapy/issues/8367), [#8393](https://github.com/scrapy/scrapy/issues/8393))
- New dependencies:
  - [aiodns](https://github.com/aio-libs/aiodns) >= 3.3.0
  - [aioftp](https://github.com/aio-libs/aioftp) >= 0.26.1
  - [formerly](https://github.com/scrapy/formerly) >= 0.1.0
  - [frostwork](https://github.com/scrapy/frostwork) >= 0.2.2
  - [typing-extensions](https://github.com/python/typing_extensions) >= 4.13.0 (on Python 3.12 and lower)

  ([#7894](https://github.com/scrapy/scrapy/issues/7894), [#8213](https://github.com/scrapy/scrapy/issues/8213), [#8303](https://github.com/scrapy/scrapy/issues/8303), [#8376](https://github.com/scrapy/scrapy/issues/8376), [#8378](https://github.com/scrapy/scrapy/issues/8378), [#8393](https://github.com/scrapy/scrapy/issues/8393))
- [charset-normalizer](https://charset-normalizer.readthedocs.io/en/latest/) is no longer a dependency.
  ([#8393](https://github.com/scrapy/scrapy/issues/8393))
- Increased the minimum versions of the following dependencies:
  - [cssselect](https://github.com/scrapy/cssselect): 0.9.1 → 1.2.0
  - [itemloaders](https://github.com/scrapy/itemloaders): 1.0.1 → 1.0.5
  - [lxml](https://lxml.de/): 4.6.4 → 4.9.4
  - [parsel](https://github.com/scrapy/parsel): 1.5.0 → 1.8.1
  - [Protego](https://github.com/scrapy/protego): 0.1.15 → 0.2.0
  - [queuelib](https://github.com/scrapy/queuelib): 1.6.1 → 1.8.0
  - [Twisted](https://twisted.org/): 21.7.0 → 23.10.0
  - [w3lib](https://github.com/scrapy/w3lib): 2.1.1 → 2.6.0

  ([#6430](https://github.com/scrapy/scrapy/issues/6430), [#8195](https://github.com/scrapy/scrapy/issues/8195), [#8261](https://github.com/scrapy/scrapy/issues/8261), [#8303](https://github.com/scrapy/scrapy/issues/8303), [#8393](https://github.com/scrapy/scrapy/issues/8393), [#8460](https://github.com/scrapy/scrapy/issues/8460))
- Changes to [extras](intro/install.md "Optional extras"):
  - New `clipboard`, `memusage` and `socks` extras.
  - `gcs`: [google-cloud-storage](https://github.com/googleapis/python-storage) 1.29.0 → 1.30.0
  - `httpx`: [httpx2](https://github.com/pydantic/httpx2) 2.0.0 → 2.3.0
  - `images`: [Pillow](https://github.com/python-pillow/Pillow) 8.3.2 → 9.2.0
  - `s3`: [boto3](https://github.com/boto/boto3) 1.20.0 → 1.35.2, and [aioboto3](https://github.com/terricain/aioboto3) >= 9.0.0 is now
    included.
  - `twisted-http2`: [Twisted](https://twisted.org/) 21.7.0 → 23.10.0
  - `uvloop`: [uvloop](https://github.com/MagicStack/uvloop) 0.16.0 → 0.17.0

  ([#6430](https://github.com/scrapy/scrapy/issues/6430), [#7826](https://github.com/scrapy/scrapy/issues/7826), [#7932](https://github.com/scrapy/scrapy/issues/7932), [#8058](https://github.com/scrapy/scrapy/issues/8058), [#8062](https://github.com/scrapy/scrapy/issues/8062), [#8162](https://github.com/scrapy/scrapy/issues/8162),
  [#8213](https://github.com/scrapy/scrapy/issues/8213), [#8261](https://github.com/scrapy/scrapy/issues/8261), [#8330](https://github.com/scrapy/scrapy/issues/8330), [#8341](https://github.com/scrapy/scrapy/issues/8341), [#8460](https://github.com/scrapy/scrapy/issues/8460))

### Backward-incompatible changes

- Changes to the `fetch()` shortcut of the [Scrapy shell](topics/shell.md):
  - Requests are now downloaded with
    [`ExecutionEngine.download_async()`](topics/api.md) instead of being
    passed to the scheduler. As a result, spider middlewares and duplicate
    filtering are no longer applied to them.
  - When a [`Request`](topics/request-response.md) 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`](topics/signals.md) and
    [`engine_stopped`](topics/signals.md) signals are not sent, and components that start
    on them, such as the [`MemoryUsage`](topics/extensions.md)
    extension and the [telnet console](topics/telnetconsole.md), do not
    run in the shell.

  ([#8174](https://github.com/scrapy/scrapy/issues/8174), [#8176](https://github.com/scrapy/scrapy/issues/8176), [#8179](https://github.com/scrapy/scrapy/issues/8179))
- Changes to the behavior of [`ExecutionEngine`](topics/api.md)
  methods that change its state:
  - [`close_spider_async()`](topics/api.md) 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()`](topics/api.md) now just calls
    [`close_spider_async()`](topics/api.md) with the
    `shutdown` reason. Calling it after
    [`open_spider_async()`](topics/api.md) and before
    [`start_async()`](topics/api.md) 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()`](topics/api.md) now raises
    `RuntimeError` if called before
    [`open_spider_async()`](topics/api.md) has
    finished, instead of sending the [`engine_started`](topics/signals.md) signal
    anyway, and if called after the engine has stopped.
  - The [`engine_stopped`](topics/signals.md) signal is now sent only after all
    [`engine_started`](topics/signals.md) handlers have finished.
  - If the spider is closed before the engine is started, for example by
    calling [`close_spider_async()`](topics/api.md)
    from a [`spider_opened`](topics/signals.md) handler, the [`engine_started`](topics/signals.md) and
    [`engine_stopped`](topics/signals.md) signals are not sent.
  - [`Crawler.stop_async()`](topics/api.md), 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`](topics/exceptions.md) 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()`](topics/api.md).
  - `crawl()` and
    [`download_async()`](topics/api.md) now raise
    `RuntimeError` when called while the spider is closing, once the
    close has stopped waiting for the requests in progress.

  ([#6916](https://github.com/scrapy/scrapy/issues/6916), [#8217](https://github.com/scrapy/scrapy/issues/8217), [#8272](https://github.com/scrapy/scrapy/issues/8272), [#8319](https://github.com/scrapy/scrapy/issues/8319))
- Setting the [`ExecutionEngine.running`](topics/api.md) attribute no longer has any
  effect, and is deprecated. Its value is now `False` while the spider is
  closing.
  ([#8181](https://github.com/scrapy/scrapy/issues/8181))
- [`FTPDownloadHandler`](topics/download-handlers.md) now
  enforces [`DOWNLOAD_MAXSIZE`](topics/settings.md) and [`DOWNLOAD_WARNSIZE`](topics/settings.md), also
  when using [`ftp_local_filename`](topics/request-response.md), 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`](topics/settings.md) or with the
  [`download_maxsize`](topics/settings.md) request meta key for specific requests. You can
  also set the limit to `0` to lift it altogether.
  ([#8213](https://github.com/scrapy/scrapy/issues/8213))
- The built-in HTTP download handlers now limit their open connections with
  the new [`CONCURRENT_CONNECTIONS_PER_HANDLER`](topics/settings.md) setting, whose
  default value is derived from the limit of open files of the process, or
  is 480 on Windows.
  [`HTTP11DownloadHandler`](topics/download-handlers.md) and
  [`H2DownloadHandler`](topics/download-handlers.md) had no
  such limit before, and
  [`AiohttpDownloadHandler`](topics/download-handlers.md)
  and [`HttpxDownloadHandler`](topics/download-handlers.md)
  used [`CONCURRENT_REQUESTS`](topics/settings.md) as their limit. If you set
  [`CONCURRENT_REQUESTS`](topics/settings.md) higher than that default, a warning is
  logged, and you need to set [`CONCURRENT_CONNECTIONS_PER_HANDLER`](topics/settings.md)
  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](faq.md)).
  ([#2653](https://github.com/scrapy/scrapy/issues/2653), [#5024](https://github.com/scrapy/scrapy/issues/5024), [#5618](https://github.com/scrapy/scrapy/issues/5618), [#7932](https://github.com/scrapy/scrapy/issues/7932))
- [`HttpxDownloadHandler`](topics/download-handlers.md) no
  longer falls back to the `httpx` package when [httpx2](https://github.com/pydantic/httpx2) is not installed.
  Install the `httpx` [extra](intro/install.md "Optional extras") to use it.
  ([#7932](https://github.com/scrapy/scrapy/issues/7932))
- Responses that your code keeps in memory, e.g. in the
  [`Request.meta`](topics/request-response.md) of scheduled requests or in component attributes,
  now count toward [`RESPONSE_MAX_ACTIVE_SIZE`](topics/settings.md) 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](topics/leaks.md).

  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`](topics/stats.md) stat.

  Scrapy itself no longer keeps responses alive in reference cycles after a
  request fails, e.g. with an
  [`HttpError`](topics/spider-middleware.md) that no errback
  handles, or after a failed media pipeline download.

  ([#6430](https://github.com/scrapy/scrapy/issues/6430), [#8417](https://github.com/scrapy/scrapy/issues/8417), [#8459](https://github.com/scrapy/scrapy/issues/8459), [#8460](https://github.com/scrapy/scrapy/issues/8460))
- Header names in `Headers` objects, i.e. in [`Request.headers`](topics/request-response.md) and [`Response.headers`](topics/request-response.md), 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`](topics/download-handlers.md)
  and [`HttpxDownloadHandler`](topics/download-handlers.md)
  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](topics/download-handlers.md "Built-in HTTP download handlers reference").

  ([#2711](https://github.com/scrapy/scrapy/issues/2711), [#7893](https://github.com/scrapy/scrapy/issues/7893), [#8265](https://github.com/scrapy/scrapy/issues/8265))
- [`get_retry_request()`](topics/downloader-middleware.md), and hence
  [`RetryMiddleware`](topics/downloader-middleware.md), now sets the
  new [`skip_dupefilter_once`](topics/request-response.md) request meta key on retry requests
  instead of setting their [`dont_filter`](topics/request-response.md) 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](https://github.com/scrapy/scrapy/issues/6895), [#8224](https://github.com/scrapy/scrapy/issues/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`](topics/settings.md) request meta key you
  set keep that slot, so set it to keep redirects and retries in the slot of
  the original request.
  ([#8337](https://github.com/scrapy/scrapy/issues/8337))
- [`http_user`](topics/request-response.md) and [`http_pass`](topics/request-response.md) 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`](topics/request-response.md) request meta key.
  [`HttpAuthMiddleware`](topics/downloader-middleware.md) also no
  longer sets the `Authorization` header of requests whose URL scheme is
  neither `http` nor `https`.
  ([#8329](https://github.com/scrapy/scrapy/issues/8329))
- Keys of [component priority dictionaries](topics/settings.md), such as
  [`DOWNLOADER_MIDDLEWARES`](topics/settings.md), 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](https://github.com/scrapy/scrapy/issues/7820), [#8159](https://github.com/scrapy/scrapy/issues/8159))
- [`HttpCompressionMiddleware`](topics/downloader-middleware.md)
  now raises [`DecompressionError`](topics/exceptions.md) for a response body
  that cannot be decompressed, instead of the exception of the underlying
  decompression library, e.g. [`zlib.error`](https://docs.python.org/3/library/zlib.html#zlib.error), `OSError` or
  `EOFError`. Update any code that catches those exceptions, e.g. in
  request errbacks.
  ([#8177](https://github.com/scrapy/scrapy/issues/8177))
- `str()` of a [`Spider`](topics/spiders.md) object now returns its
  [`name`](topics/spiders.md). Use `repr()` to get the previous output,
  e.g. `<MySpider 'my_spider' at 0x7f0e2c1a3b50>`.
  ([#1576](https://github.com/scrapy/scrapy/issues/1576), [#8086](https://github.com/scrapy/scrapy/issues/8086))
- The `scrapy.utils.defer.parallel()` and
  `scrapy.utils.defer.parallel_async()` functions, now deprecated, return a
  [`Deferred`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.Deferred.html) that fires with `None`, instead
  of with the result list of a [`DeferredList`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.DeferredList.html).
  ([#5182](https://github.com/scrapy/scrapy/issues/5182), [#7959](https://github.com/scrapy/scrapy/issues/7959))
- The `process_response()` method of [`HttpCompressionMiddleware`](topics/downloader-middleware.md)
  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](https://github.com/scrapy/scrapy/issues/3751), [#8153](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/5622), [#6273](https://github.com/scrapy/scrapy/issues/6273), [#7800](https://github.com/scrapy/scrapy/issues/7800))
- `parent_id` is now part of [`Request.attributes`](topics/request-response.md), so [`Request.replace()`](topics/request-response.md) and
  [`request_from_dict()`](topics/request-response.md) pass a `parent_id`
  keyword argument to the request class. [`Request`](topics/request-response.md) subclasses
  whose `__init__()` method accepts neither `parent_id` nor
  `**kwargs` must be updated.
  ([#8225](https://github.com/scrapy/scrapy/issues/8225))
- [Item exporters](topics/exporters.md) 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`](topics/exporters.md),
  [`MarshalItemExporter`](topics/exporters.md),
  [`PprintItemExporter`](topics/exporters.md) and custom
  [`BaseItemExporter`](topics/exporters.md) subclasses, and
  [`CsvItemExporter`](topics/exporters.md) now joins list-like values,
  e.g. sets, the way it joins lists.
  ([#3888](https://github.com/scrapy/scrapy/issues/3888), [#3890](https://github.com/scrapy/scrapy/issues/3890), [#8057](https://github.com/scrapy/scrapy/issues/8057))
- The output of a request [errback](topics/request-response.md "Errbacks") that runs because a
  download failed now goes through the
  [`process_spider_output()`](topics/spider-middleware.md)
  methods of [spider middlewares](topics/spider-middleware.md), with
  `None` as the response, and exceptions raised while iterating that output
  reach their
  [`process_spider_exception()`](topics/spider-middleware.md)
  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`](topics/spider-middleware.md) can
  drop requests from such errbacks, and
  [`StartSpiderMiddleware`](topics/spider-middleware.md) now sets
  [`is_start_request`](topics/spider-middleware.md) in its `process_start()` method instead of in
  `get_processed_request()`.
  ([#4999](https://github.com/scrapy/scrapy/issues/4999), [#7992](https://github.com/scrapy/scrapy/issues/7992))
- Feed storages now refuse [feed modes](topics/feed-exports.md "FEED_MODE") that they do not
  support, which prevents the crawl from starting. In particular, setting
  the `overwrite` feed option to `False` for an [S3](topics/feed-exports.md) feed, which used to log a warning, now raises
  `ValueError`. For a [GCS](topics/feed-exports.md "Google Cloud Storage (GCS)") feed, which
  used to log a warning and overwrite the file, it now appends to the file.
  ([#5580](https://github.com/scrapy/scrapy/issues/5580), [#7826](https://github.com/scrapy/scrapy/issues/7826), [#8173](https://github.com/scrapy/scrapy/issues/8173))
- [`sitemap_follow`](topics/spiders.md) 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](https://github.com/scrapy/scrapy/issues/1182), [#8175](https://github.com/scrapy/scrapy/issues/8175))
- The `process_request()` method of
  [`HttpCacheMiddleware`](topics/downloader-middleware.md) 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](https://github.com/scrapy/scrapy/issues/2744), [#7915](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/8392))
- The settings of the built-in storages of [media pipelines](topics/media-pipeline.md) are no longer set as class attributes of those
  storages, e.g. `S3FilesStore.POLICY` keeps its default value regardless
  of [`FILES_STORE_S3_ACL`](topics/media-pipeline.md). Read them from the storage object of the
  pipeline instead, e.g. `pipeline.store.POLICY`.
  ([#7925](https://github.com/scrapy/scrapy/issues/7925))
- `Scraper.slot` and the deprecated `scrapy.core.scraper.Slot` class
  now take a [`Crawler`](topics/api.md) 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](https://github.com/scrapy/scrapy/issues/6430))
- The engine status that the [telnet console](topics/telnetconsole.md)
  reports now includes `engine.response_active_size` instead of
  `engine.scraper.slot.active_size` and
  `engine.scraper.slot.needs_backout()`.
  ([#6430](https://github.com/scrapy/scrapy/issues/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`](topics/downloader-middleware.md) is set with the same or a higher
  [priority](topics/settings.md "Populating the settings").
  ([#8393](https://github.com/scrapy/scrapy/issues/8393))
- Scrapy no longer calls the deprecated `spider_opened()` and
  `spider_closed()` methods of
  [`SpiderState`](topics/extensions.md), so overriding them in
  a subclass has no effect. Handle the [`spider_state_loaded`](topics/signals.md) and
  [`spider_state_saving`](topics/signals.md) signals instead.
  ([#5153](https://github.com/scrapy/scrapy/issues/5153), [#7650](https://github.com/scrapy/scrapy/issues/7650), [#7656](https://github.com/scrapy/scrapy/issues/7656))
- Due to the new minimum version of [w3lib](https://github.com/scrapy/w3lib), 2.6.0:
  - Request URLs are now normalized the way web browsers normalize them, so
    [`Request.url`](topics/request-response.md) and [`Response.url`](topics/request-response.md) 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](topics/request-response.md) might differ for some
    URLs, so that cached responses of
    [`HttpCacheMiddleware`](topics/downloader-middleware.md) and
    the seen requests of a [job directory](topics/jobs.md) from an earlier
    version might not match the same requests.

  ([#8393](https://github.com/scrapy/scrapy/issues/8393))
- For encodings declared in the response, [`TextResponse.encoding`](topics/request-response.md) 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`](topics/request-response.md) instead of
  `response.body.decode(response.encoding)`.

  [`TextResponse.text`](topics/request-response.md) 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](https://github.com/scrapy/scrapy/issues/8393))
- The base URL of a response, used by [`TextResponse.urljoin()`](topics/request-response.md), [selectors](topics/selectors.md)
  and [link extractors](topics/link-extractors.md), and the meta refresh
  that [`MetaRefreshMiddleware`](topics/downloader-middleware.md)
  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](https://github.com/scrapy/scrapy/issues/8393))
- The `response` attribute of [`Selector`](topics/selectors.md) objects is now
  read-only. For the selector of a response, i.e.
  [`TextResponse.selector`](topics/request-response.md), it no
  longer keeps the response alive, and becomes `None` once nothing else
  refers to the response.
  ([#8245](https://github.com/scrapy/scrapy/issues/8245))
- A negative value of [`FILES_EXPIRES`](topics/media-pipeline.md) or [`IMAGES_EXPIRES`](topics/media-pipeline.md)
  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](https://github.com/scrapy/scrapy/issues/8046))
- Crawls closed because [`start()`](topics/spiders.md) raised an exception, or
  by [`CLOSESPIDER_ERRORCOUNT`](topics/extensions.md), now make the [`crawl`](topics/commands.md) and
  [`runspider`](topics/commands.md) commands exit with code 1.
  ([#8082](https://github.com/scrapy/scrapy/issues/8082), [#8203](https://github.com/scrapy/scrapy/issues/8203))
- A blank line between [contract](topics/contracts.md) 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](https://github.com/scrapy/scrapy/issues/768), [#8043](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7766), [#8135](https://github.com/scrapy/scrapy/issues/8135), [#8146](https://github.com/scrapy/scrapy/issues/8146), [#8270](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/8175), [#8288](https://github.com/scrapy/scrapy/issues/8288), [#8350](https://github.com/scrapy/scrapy/issues/8350), [#8363](https://github.com/scrapy/scrapy/issues/8363), [#8414](https://github.com/scrapy/scrapy/issues/8414))
- `scrapy.utils.python.garbage_collect()` is deprecated, use
  [`gc.collect()`](https://docs.python.org/3/library/gc.html#gc.collect) instead.
  ([#8367](https://github.com/scrapy/scrapy/issues/8367))
- Passing a coroutine to `scrapy.utils.spider.iterate_spider_output()`, for
  which it returns a [`Deferred`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.Deferred.html) instead of an
  iterable, is deprecated. Await the coroutine and pass its result instead.
  ([#8394](https://github.com/scrapy/scrapy/issues/8394))
- Passing a synchronous iterable to
  `scrapy.core.scraper.Scraper.handle_spider_output_async()` is deprecated,
  pass an asynchronous iterable instead.
  ([#8288](https://github.com/scrapy/scrapy/issues/8288))
- `scrapy.utils.reactor.is_asyncio_reactor_installed()` is deprecated. To
  check for asyncio support, use
  [`is_asyncio_available()`](topics/asyncio.md). To check whether a
  reactor is installed, use `scrapy.utils.reactor.is_reactor_installed()`.
  See [Supporting older Scrapy versions](topics/asyncio.md) for code that must also support older
  Scrapy versions.
  ([#8128](https://github.com/scrapy/scrapy/issues/8128), [#8454](https://github.com/scrapy/scrapy/issues/8454))
- Defining a `parse_item()` method in a
  [`XMLFeedSpider`](topics/spiders.md) subclass is deprecated. Define
  [`parse_node()`](topics/spiders.md) instead.
  ([#8147](https://github.com/scrapy/scrapy/issues/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`](topics/downloader-middleware.md) can retry
  them. Because existing `process_exception()` methods may not expect those
  exceptions, e.g. the [`IgnoreRequest`](topics/exceptions.md) raised to drop
  a response, this only happens when the new
  [`DOWNLOADER_MIDDLEWARE_RESPONSE_EXCEPTIONS`](topics/settings.md) 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`](topics/commands.md) already do.
  ([#7790](https://github.com/scrapy/scrapy/issues/7790), [#8177](https://github.com/scrapy/scrapy/issues/8177))
- `scrapy.utils.deprecate.create_deprecated_class()` is deprecated, use
  `formerly.deprecated_class()` from [formerly](https://github.com/scrapy/formerly) instead.
  `scrapy.utils.decorators.deprecated()` is deprecated, use
  [`warnings.deprecated()`](https://docs.python.org/3/library/warnings.html#warnings.deprecated) instead (or `typing_extensions.deprecated()`
  on Python 3.12 and lower).
  ([#7894](https://github.com/scrapy/scrapy/issues/7894))
- `scrapy.utils.url.add_http_if_no_scheme()` is deprecated. Use
  [`w3lib.url.add_http_if_no_scheme()`](https://w3lib.readthedocs.io/en/latest/w3lib.html#w3lib.url.add_http_if_no_scheme) instead.
  ([#2186](https://github.com/scrapy/scrapy/issues/2186), [#8189](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/8259), [#8264](https://github.com/scrapy/scrapy/issues/8264))
- The `spider_closed_callback` parameter of
  [`ExecutionEngine`](topics/api.md) is deprecated. Closing the
  spider now stops the engine, and [`Crawler.crawl_async()`](topics/api.md) completes when that happens.
  ([#6916](https://github.com/scrapy/scrapy/issues/6916), [#8217](https://github.com/scrapy/scrapy/issues/8217))
- Setting the [`ExecutionEngine.running`](topics/api.md) attribute is deprecated, and
  has no effect.
  ([#8181](https://github.com/scrapy/scrapy/issues/8181))
- Custom [schedulers](topics/scheduler.md) that do not set
  [`supports_skip_dupefilter_once`](topics/scheduler.md)
  to `True` are deprecated, including subclasses of the default scheduler
  that override its
  [`enqueue_request()`](topics/scheduler.md) method.
  Scrapy turns [`skip_dupefilter_once`](topics/request-response.md) into `dont_filter=True` for
  them, with a warning. To update a scheduler,
  handle [`skip_dupefilter_once`](topics/request-response.md) in its
  [`enqueue_request()`](topics/scheduler.md) method and
  set
  [`supports_skip_dupefilter_once`](topics/scheduler.md)
  to `True`.
  ([#6895](https://github.com/scrapy/scrapy/issues/6895), [#8224](https://github.com/scrapy/scrapy/issues/8224))
- The `overwrite` feed option is deprecated. Use the new `mode`
  [feed option](topics/feed-exports.md "FEED_MODE") instead: `"overwrite"` instead of
  `True`, `"append"` instead of `False`. The `overwrite` attribute of
  [`FTPFeedStorage`](topics/feed-exports.md) is deprecated as
  well.

  The default value of the new [`FEED_MODE`](topics/feed-exports.md) 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`](topics/feed-exports.md), or the `mode` option of every feed, to silence the
  deprecation warning. New projects set [`FEED_MODE`](topics/feed-exports.md) to `"create"`
  in their `settings.py` file.
  ([#5580](https://github.com/scrapy/scrapy/issues/5580), [#7826](https://github.com/scrapy/scrapy/issues/7826))
- The `STORE_SCHEMES` attribute of
  [`FilesPipeline`](topics/media-pipeline.md) is deprecated. Use the new
  [`MEDIA_STORAGES`](topics/media-pipeline.md) setting instead.
  ([#5991](https://github.com/scrapy/scrapy/issues/5991), [#7925](https://github.com/scrapy/scrapy/issues/7925))
- The `spider_opened()` and `spider_closed()` methods of
  [`SpiderState`](topics/extensions.md) are deprecated. Use the
  new [`spider_state_loaded`](topics/signals.md) and [`spider_state_saving`](topics/signals.md)
  signals instead.
  ([#5153](https://github.com/scrapy/scrapy/issues/5153), [#7650](https://github.com/scrapy/scrapy/issues/7650), [#7656](https://github.com/scrapy/scrapy/issues/7656))
- The *spider* and *to_native_str_type* parameters of
  `scrapy.robotstxt.decode_robotstxt()` are deprecated and have no effect.
  ([#8316](https://github.com/scrapy/scrapy/issues/8316))
- Calling [`AsyncCrawlerRunner.crawl()`](topics/api.md) without a running asyncio event
  loop while [`TWISTED_REACTOR_ENABLED`](topics/settings.md) is `False` is deprecated.
  Call it from a coroutine that runs in the event loop instead, e.g. one
  passed to [`asyncio.run()`](https://docs.python.org/3/library/asyncio-runner.html#asyncio.run).
  ([#7201](https://github.com/scrapy/scrapy/issues/7201), [#7681](https://github.com/scrapy/scrapy/issues/7681), [#8327](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/8198), [#8457](https://github.com/scrapy/scrapy/issues/8457))
- The `SCRAPER_SLOT_MAX_ACTIVE_SIZE` setting is deprecated. Use
  [`RESPONSE_MAX_ACTIVE_SIZE`](topics/settings.md) 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`](topics/api.md),
  [`RESPONSE_MAX_ACTIVE_SIZE`](topics/settings.md) and
  [`ExecutionEngine.needs_backout()`](topics/api.md) instead.

  ([#6430](https://github.com/scrapy/scrapy/issues/6430))
- Using a Twisted reactor other than
  [`AsyncioSelectorReactor`](https://docs.twisted.org/en/stable/api/twisted.internet.asyncioreactor.AsyncioSelectorReactor.html) is
  deprecated, be it set through the `TWISTED_REACTOR` setting, installed
  by code outside Scrapy, or passed to
  [`install_reactor()`](topics/asyncio.md). 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](https://github.com/scrapy/scrapy/issues/8111), [#8454](https://github.com/scrapy/scrapy/issues/8454))
- Passing an encoding that web browsers do not support, e.g. `cp437`, to
  the *encoding* parameter of [`TextResponse`](topics/request-response.md) is
  deprecated. To decode a response body with such an encoding, use
  `response.body.decode(encoding)`.
  ([#8393](https://github.com/scrapy/scrapy/issues/8393))
- `scrapy.utils.response.get_base_url()` and
  `scrapy.utils.response.get_meta_refresh()` are deprecated. Use the new
  [`TextResponse.base_url`](topics/request-response.md) and
  [`TextResponse.meta_refresh`](topics/request-response.md)
  attributes instead. When there is no meta refresh, the latter is `None`
  instead of `(None, None)`.
  ([#8393](https://github.com/scrapy/scrapy/issues/8393))
- The `METAREFRESH_IGNORE_TAGS` setting is deprecated. Use the new
  [`METAREFRESH_SCRIPTING`](topics/downloader-middleware.md) setting instead.
  ([#8393](https://github.com/scrapy/scrapy/issues/8393))

### New features

- [`Request`](topics/request-response.md) objects can now be awaited, e.g. in a spider
  callback, to send them and get their response. See [Inline requests](topics/coroutines.md).
  ([#1144](https://github.com/scrapy/scrapy/issues/1144), [#8207](https://github.com/scrapy/scrapy/issues/8207))
- Added a [`DOWNLOAD_HANDLERS_BY_NAME`](topics/settings.md) setting and a
  [`download_handler`](topics/request-response.md) request meta key, to [choose a download
  handler per request](topics/download-handlers.md "Choosing a download handler per request"), e.g. a browser-based handler
  for only some requests. The default [request fingerprinter](topics/request-response.md "Request fingerprints") takes [`download_handler`](topics/request-response.md) into account
  when it does not match the URL scheme.

  [`RobotsTxtMiddleware`](topics/downloader-middleware.md) now
  copies [`download_handler`](topics/request-response.md) from the request that triggers a
  `robots.txt` request, and sets the new [`is_robotstxt_request`](topics/request-response.md)
  request meta key on the `robots.txt` requests that it sends.

  ([#5510](https://github.com/scrapy/scrapy/issues/5510), [#7885](https://github.com/scrapy/scrapy/issues/7885))
- Added a [`body_file`](topics/request-response.md) 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](topics/download-handlers.md "Built-in HTTP download handlers reference"). Set it to a file path, or to
  `True` to write into a new temporary file. Those requests get a
  [`BodyFileResponse`](topics/request-response.md), and neither they nor their
  responses count toward [`RESPONSE_MAX_ACTIVE_SIZE`](topics/settings.md).
  ([#3880](https://github.com/scrapy/scrapy/issues/3880), [#4620](https://github.com/scrapy/scrapy/issues/4620), [#5044](https://github.com/scrapy/scrapy/issues/5044), [#7987](https://github.com/scrapy/scrapy/issues/7987), [#8466](https://github.com/scrapy/scrapy/issues/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()`](topics/api.md),
  [`CrawlerRunner.stop()`](topics/api.md) and
  [`AsyncCrawlerRunner.stop()`](topics/api.md)
  have a new keyword-only `mode` parameter that can be `"graceful"` (the
  default), `"fast"` or `"force"`, which works as `"fast"` unless you
  use [`CrawlerProcess`](topics/api.md) or
  [`AsyncCrawlerProcess`](topics/api.md).
  [`stop_async()`](topics/api.md) and
  [`close_spider_async()`](topics/api.md) accept
  `"graceful"` and `"fast"`. A custom [`DOWNLOADER`](topics/settings.md) class needs
  a `stop()` coroutine method, returning the number of dropped requests,
  for fast stops to drop its downloads.
  ([#4749](https://github.com/scrapy/scrapy/issues/4749), [#5000](https://github.com/scrapy/scrapy/issues/5000), [#7455](https://github.com/scrapy/scrapy/issues/7455), [#8296](https://github.com/scrapy/scrapy/issues/8296), [#8312](https://github.com/scrapy/scrapy/issues/8312))
- Added the [`delay`](topics/request-response.md) request meta key, which holds a request for at
  least the given number of seconds before sending it, and the
  [`delayed`](topics/request-response.md) request meta key, which lists the delays that a request
  has been held for.
  ([#802](https://github.com/scrapy/scrapy/issues/802), [#3835](https://github.com/scrapy/scrapy/issues/3835), [#4980](https://github.com/scrapy/scrapy/issues/4980), [#5015](https://github.com/scrapy/scrapy/issues/5015), [#7873](https://github.com/scrapy/scrapy/issues/7873))
- Added [`TextResponse.base_url`](topics/request-response.md) and
  [`TextResponse.meta_refresh`](topics/request-response.md),
  which return the base URL of a response and the
  [`MetaRefresh`](topics/request-response.md) that a web browser with
  JavaScript enabled would follow, and which you can set to override what the
  response body says. When [`METAREFRESH_SCRIPTING`](topics/downloader-middleware.md) is `False`,
  [`MetaRefreshMiddleware`](topics/downloader-middleware.md)
  ignores an overridden [`meta_refresh`](topics/request-response.md).
  ([#8393](https://github.com/scrapy/scrapy/issues/8393))
- Added a [`METAREFRESH_SCRIPTING`](topics/downloader-middleware.md) setting, which you can set to
  `False` to follow the meta refresh that a web browser with JavaScript
  disabled would follow.
  ([#8393](https://github.com/scrapy/scrapy/issues/8393))
- Added a [`FEED_MODE`](topics/feed-exports.md) setting and a `mode` [feed option](topics/feed-exports.md), 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`](topics/feed-exports.md)
  attribute.

  The `-o` command-line option also follows [`FEED_MODE`](topics/feed-exports.md), so in a
  project with [`FEED_MODE`](topics/feed-exports.md) set to `"create"`, `-o` leaves an
  existing file untouched. Use `-O` to overwrite it.
  ([#5580](https://github.com/scrapy/scrapy/issues/5580), [#7826](https://github.com/scrapy/scrapy/issues/7826))
- Added [`DiskDupeFilter`](topics/settings.md), a
  [`DUPEFILTER_CLASS`](topics/settings.md) that keeps request fingerprints in an SQLite
  database on disk instead of in memory, to lower memory usage on large
  crawls.
  ([#5307](https://github.com/scrapy/scrapy/issues/5307), [#7952](https://github.com/scrapy/scrapy/issues/7952))
- Added a [`JOBDIR_SYNC_EVERY`](topics/settings.md) setting to write the
  `active.json` file of the [job directory](topics/jobs.md), and the
  database of [`DiskDupeFilter`](topics/settings.md), 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`](topics/settings.md) and
  [`SCHEDULER_START_DISK_QUEUE`](topics/settings.md) use SQLite-based queues. Custom
  [`SCHEDULER_PRIORITY_QUEUE`](topics/settings.md) classes need the new
  [`changed`](topics/scheduler.md) attribute and
  [`state()`](topics/scheduler.md) method to support it.

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

  ([#7978](https://github.com/scrapy/scrapy/issues/7978), [#8152](https://github.com/scrapy/scrapy/issues/8152), [#8322](https://github.com/scrapy/scrapy/issues/8322))
- Added [`Request.id`](topics/request-response.md), a unique identifier of each
  request, and [`Request.parent_id`](topics/request-response.md), the
  [`id`](topics/request-response.md) of the request it derives from, which Scrapy
  sets for requests from callbacks and errbacks, from
  [`Response.follow()`](topics/request-response.md) and from
  [`Request.replace()`](topics/request-response.md), e.g. redirects and
  retries. Use the new *parent_id* parameter of [`Request`](topics/request-response.md) 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](topics/jobs.md).
  ([#8225](https://github.com/scrapy/scrapy/issues/8225))
- Added a [`genrequest`](topics/commands.md) command, which prints the Python code of a
  [`Request`](topics/request-response.md) object equivalent to a cURL command, given as an
  argument or read from the system clipboard with the new `clipboard`
  [extra](intro/install.md "Optional extras").
  ([#3990](https://github.com/scrapy/scrapy/issues/3990), [#3991](https://github.com/scrapy/scrapy/issues/3991), [#8058](https://github.com/scrapy/scrapy/issues/8058))
- Added a [`complete`](topics/commands.md) command, which prints a [shell completion](topics/commands.md) 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()`](topics/commands.md) and
  [`complete_option()`](topics/commands.md) methods. It replaces
  the completion scripts that were in the `extras` directory of the
  source code repository.
  ([#6453](https://github.com/scrapy/scrapy/issues/6453), [#7899](https://github.com/scrapy/scrapy/issues/7899))
- Added a [`STICKY_META_KEYS`](topics/settings.md) setting to copy request metadata keys
  from a response into the follow-up requests yielded by its callback,
  handled by the new
  [`StickyMetaParamsMiddleware`](topics/spider-middleware.md).

  The new middleware has priority 1000 in
  [`SPIDER_MIDDLEWARES_BASE`](topics/settings.md), and
  [`MetaCopyDetectionMiddleware`](topics/spider-middleware.md)
  moved from 1000 to 999.

  ([#3645](https://github.com/scrapy/scrapy/issues/3645), [#3770](https://github.com/scrapy/scrapy/issues/3770), [#4141](https://github.com/scrapy/scrapy/issues/4141), [#7711](https://github.com/scrapy/scrapy/issues/7711), [#8166](https://github.com/scrapy/scrapy/issues/8166))
- [`Rule`](topics/spiders.md) has new `name` and `from_rules`
  parameters, to apply a rule only to responses reached through specific
  other rules.
  ([#982](https://github.com/scrapy/scrapy/issues/982), [#8066](https://github.com/scrapy/scrapy/issues/8066))
- A callback docstring can now define several batches of [contracts](topics/contracts.md), 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`](topics/contracts.md) to `True` to behave like `@url`.
  ([#768](https://github.com/scrapy/scrapy/issues/768), [#8043](https://github.com/scrapy/scrapy/issues/8043))
- The [Google Cloud Storage feed storage](topics/feed-exports.md "Google Cloud Storage (GCS)") now
  supports the `"append"` [feed mode](topics/feed-exports.md "FEED_MODE"), instead of logging
  a warning and overwriting the feed.
  ([#7823](https://github.com/scrapy/scrapy/issues/7823), [#8173](https://github.com/scrapy/scrapy/issues/8173))
- [`FILES_EXPIRES`](topics/media-pipeline.md) and [`IMAGES_EXPIRES`](topics/media-pipeline.md) 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](https://github.com/scrapy/scrapy/issues/2309), [#4731](https://github.com/scrapy/scrapy/issues/4731), [#8046](https://github.com/scrapy/scrapy/issues/8046))
- The *reactor_path* parameter of
  [`install_reactor()`](topics/asyncio.md) is now optional, and
  defaults to the asyncio reactor.
  ([#8125](https://github.com/scrapy/scrapy/issues/8125))
- Added a [`DOWNLOADER_MIDDLEWARE_RESPONSE_EXCEPTIONS`](topics/settings.md) 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`](topics/downloader-middleware.md) to
  retry responses that other middlewares reject, e.g. responses that cannot
  be decompressed, for which [`DecompressionError`](topics/exceptions.md) is
  now part of [`RETRY_EXCEPTIONS`](topics/downloader-middleware.md).
  ([#1900](https://github.com/scrapy/scrapy/issues/1900), [#3506](https://github.com/scrapy/scrapy/issues/3506), [#7790](https://github.com/scrapy/scrapy/issues/7790), [#8177](https://github.com/scrapy/scrapy/issues/8177))
- [`CloseSpider`](topics/exceptions.md) can now be raised from
  [downloader middlewares](topics/downloader-middleware.md) to close the
  spider.
  ([#2578](https://github.com/scrapy/scrapy/issues/2578), [#8177](https://github.com/scrapy/scrapy/issues/8177))
- Added [`JsonValidationMiddleware`](topics/downloader-middleware.md),
  with priority 560 in [`DOWNLOADER_MIDDLEWARES_BASE`](topics/settings.md) and enabled
  with the [`JSONVALIDATION_ENABLED`](topics/downloader-middleware.md) setting, which raises
  [`json.JSONDecodeError`](https://docs.python.org/3/library/json.html#json.JSONDecodeError) for successful
  [`JsonResponse`](topics/request-response.md) responses with an invalid JSON body.
  [`json.JSONDecodeError`](https://docs.python.org/3/library/json.html#json.JSONDecodeError) is now part of [`RETRY_EXCEPTIONS`](topics/downloader-middleware.md), so
  those responses are retried if
  [`DOWNLOADER_MIDDLEWARE_RESPONSE_EXCEPTIONS`](topics/settings.md) is `True`.
  ([#8215](https://github.com/scrapy/scrapy/issues/8215))
- Added an *error* keyword-only parameter to
  [`CloseSpider`](topics/exceptions.md) and
  [`close_spider_async()`](topics/api.md), to mark a
  crawl as failed. Failed crawls set the new [`finish_reason_error`](topics/stats.md) stat
  to `True`, get `error=True` in their [`spider_closed`](topics/signals.md) signal,
  and make the [`crawl`](topics/commands.md) and [`runspider`](topics/commands.md) commands exit with
  code 1. Crawls closed because [`start()`](topics/spiders.md) raised an
  exception (`start_error`) are now also marked as failed, and so are
  crawls closed by [`CLOSESPIDER_ERRORCOUNT`](topics/extensions.md).
  ([#1241](https://github.com/scrapy/scrapy/issues/1241), [#2171](https://github.com/scrapy/scrapy/issues/2171), [#3653](https://github.com/scrapy/scrapy/issues/3653), [#3654](https://github.com/scrapy/scrapy/issues/3654), [#8082](https://github.com/scrapy/scrapy/issues/8082), [#8203](https://github.com/scrapy/scrapy/issues/8203),
  [#8204](https://github.com/scrapy/scrapy/issues/8204), [#8352](https://github.com/scrapy/scrapy/issues/8352), [#8357](https://github.com/scrapy/scrapy/issues/8357))
- Added an [`IMAGES_PRESERVE_FORMAT`](topics/media-pipeline.md) setting to [keep images in
  their original format](topics/media-pipeline.md "Preserving the original image format") instead of converting them
  to JPEG. Stored images then get no file extension.
  ([#1705](https://github.com/scrapy/scrapy/issues/1705), [#2471](https://github.com/scrapy/scrapy/issues/2471), [#8198](https://github.com/scrapy/scrapy/issues/8198))
- Added an `item_processor` [feed option](topics/feed-exports.md) to
  [replace each item with any number of items](topics/feed-exports.md "Item processing") in a
  given feed, and a `feedexport/item_count/<storage class>` stat with the
  number of exported entries per storage class.
  ([#5905](https://github.com/scrapy/scrapy/issues/5905), [#7911](https://github.com/scrapy/scrapy/issues/7911))
- Added an [`UPLOAD_TIMEOUT`](topics/settings.md) setting to set how long uploads to
  remote [feed storages](topics/feed-exports.md "Storage backends") and [media
  pipeline storages](topics/media-pipeline.md) (Amazon S3, Google Cloud Storage
  and FTP) wait for a response before giving up.
  ([#5011](https://github.com/scrapy/scrapy/issues/5011), [#8162](https://github.com/scrapy/scrapy/issues/8162))
- Added a [`MEDIA_CACHE_SIZE`](topics/media-pipeline.md) setting to limit how many download
  outcomes [media pipelines](topics/media-pipeline.md) keep in memory,
  which by default they keep for the whole crawl.
  ([#939](https://github.com/scrapy/scrapy/issues/939), [#8193](https://github.com/scrapy/scrapy/issues/8193))
- [`LOG_FORMAT`](topics/logging.md) 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](https://github.com/scrapy/scrapy/issues/1576), [#8086](https://github.com/scrapy/scrapy/issues/8086))
- [`StatsCollector`](topics/stats.md) objects are now
  [`mutable mappings`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping) of stats, e.g.
  `stats["hostname"] = socket.gethostname()`.
  ([#3230](https://github.com/scrapy/scrapy/issues/3230), [#8241](https://github.com/scrapy/scrapy/issues/8241))
- The [`start_exporting()`](topics/exporters.md),
  [`export_item()`](topics/exporters.md) and
  [`finish_exporting()`](topics/exporters.md) methods of
  [item exporters](topics/exporters.md) used by [feed exports](topics/feed-exports.md), and the
  [`open()`](topics/feed-exports.md) and
  [`store()`](topics/feed-exports.md) methods of
  [feed storages](topics/feed-exports.md "Custom storage backends"), can now be coroutine
  functions.
  ([#5622](https://github.com/scrapy/scrapy/issues/5622), [#6273](https://github.com/scrapy/scrapy/issues/6273), [#7800](https://github.com/scrapy/scrapy/issues/7800))
- Added a [`LOG_LEVELS`](topics/settings.md) setting, to set the minimum log level of
  specific loggers, overriding the levels that Scrapy sets by default.
  ([#2231](https://github.com/scrapy/scrapy/issues/2231), [#7921](https://github.com/scrapy/scrapy/issues/7921))
- The [`settings`](topics/commands.md) command now takes the settings of enabled
  [add-ons](topics/addons.md) into account, and has a new `--spider`
  option to take the settings of a spider into account as well.
  ([#7010](https://github.com/scrapy/scrapy/issues/7010), [#7828](https://github.com/scrapy/scrapy/issues/7828))
- Added a [`skip_dupefilter_once`](topics/request-response.md) request meta key, which skips
  duplicate filtering for a request without affecting the requests derived
  from it, and a
  [`supports_skip_dupefilter_once`](topics/scheduler.md)
  attribute for schedulers to declare that they support it.
  ([#6895](https://github.com/scrapy/scrapy/issues/6895), [#8224](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/1478), [#2505](https://github.com/scrapy/scrapy/issues/2505), [#8197](https://github.com/scrapy/scrapy/issues/8197))
- The [memory usage extension](topics/extensions.md) now
  works on Windows, with the new `memusage` [extra](intro/install.md "Optional extras").
  ([#4070](https://github.com/scrapy/scrapy/issues/4070), [#8062](https://github.com/scrapy/scrapy/issues/8062))
- Added [`EngineState`](topics/api.md) and
  [`ExecutionEngine.state`](topics/api.md),
  which tell the lifecycle state of the engine.
  ([#6916](https://github.com/scrapy/scrapy/issues/6916), [#8217](https://github.com/scrapy/scrapy/issues/8217))
- The [`fetch`](topics/commands.md), [`view`](topics/commands.md), [`shell`](topics/commands.md) and
  [`parse`](topics/commands.md) commands now support a `--curl` option, to build the
  request from a cURL command instead of from a URL argument.
  ([#36](https://github.com/scrapy/scrapy/issues/36), [#447](https://github.com/scrapy/scrapy/issues/447), [#7703](https://github.com/scrapy/scrapy/issues/7703))
- Added an experimental FTP and FTPS download handler,
  [`AioftpDownloadHandler`](topics/download-handlers.md),
  used by default when running [without a Twisted reactor](topics/asyncio.md "Using Scrapy without a Twisted reactor"). The new `socks` [extra](intro/install.md "Optional extras")
  enables its support for SOCKS proxies.
  ([#7261](https://github.com/scrapy/scrapy/issues/7261), [#8213](https://github.com/scrapy/scrapy/issues/8213), [#8341](https://github.com/scrapy/scrapy/issues/8341))
- Added [`MEDIA_STORAGES`](topics/media-pipeline.md) and [`MEDIA_STORAGES_BASE`](topics/media-pipeline.md)
  settings, which map URL schemes to the storage classes of the [media
  pipelines](topics/media-pipeline.md), 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`](topics/media-pipeline.md) and [`IMAGES_STORE_S3_ACL`](topics/media-pipeline.md).
  ([#5991](https://github.com/scrapy/scrapy/issues/5991), [#7925](https://github.com/scrapy/scrapy/issues/7925))
- Added [`FILES_CHECKSUM_ALGORITHM`](topics/media-pipeline.md) and
  [`IMAGES_CHECKSUM_ALGORITHM`](topics/media-pipeline.md) settings, to calculate the checksums
  of [media pipeline](topics/media-pipeline.md) files with a
  [`hashlib`](https://docs.python.org/3/library/hashlib.html#module-hashlib) algorithm other than MD5.
  ([#3306](https://github.com/scrapy/scrapy/issues/3306), [#7951](https://github.com/scrapy/scrapy/issues/7951))
- [`LxmlLinkExtractor`](topics/link-extractors.md) has a new
  `schemes` parameter to choose the URL schemes of extracted links, and
  [`scrapy.linkextractors.SUPPORTED_SCHEMES`](topics/link-extractors.md) lists the URL schemes that
  Scrapy can download out of the box.
  ([#4979](https://github.com/scrapy/scrapy/issues/4979), [#7994](https://github.com/scrapy/scrapy/issues/7994))
- Added [`SitemapSpider.sitemap_request()`](topics/spiders.md), which you can override to
  customize the requests that [`SitemapSpider`](topics/spiders.md) builds
  from sitemap entries, e.g. to pass sitemap data to callbacks.
  ([#2565](https://github.com/scrapy/scrapy/issues/2565), [#3543](https://github.com/scrapy/scrapy/issues/3543), [#8175](https://github.com/scrapy/scrapy/issues/8175))
- Added a [`sitemaps()`](topics/downloader-middleware.md) method to
  [`RobotParser`](topics/downloader-middleware.md), implemented by the
  [Protego](topics/downloader-middleware.md "Protego parser") and [Robotexclusionrulesparser](topics/downloader-middleware.md) parsers, which returns the sitemap URLs declared in the
  `robots.txt` file, and a *response* parameter to the
  [`robots_parsed`](topics/signals.md) signal.
  ([#3967](https://github.com/scrapy/scrapy/issues/3967), [#8069](https://github.com/scrapy/scrapy/issues/8069), [#8175](https://github.com/scrapy/scrapy/issues/8175))
- Added the [`spider_state_loaded`](topics/signals.md), [`spider_state_saving`](topics/signals.md)
  and [`feed_slots_initialized`](topics/signals.md) signals.
  ([#5153](https://github.com/scrapy/scrapy/issues/5153), [#7650](https://github.com/scrapy/scrapy/issues/7650), [#7656](https://github.com/scrapy/scrapy/issues/7656))
- Added an [event loop lag monitor](topics/extensions.md) extension, enabled
  by default, which logs a warning when code blocks the event loop for longer
  than the new [`EVENT_LOOP_LAG_THRESHOLD`](topics/settings.md) setting, 10 seconds by
  default.
  ([#3197](https://github.com/scrapy/scrapy/issues/3197), [#8093](https://github.com/scrapy/scrapy/issues/8093))
- When [`RobotsTxtMiddleware`](topics/downloader-middleware.md)
  denies at least one [start request](topics/spiders.md "Start requests") and no start
  request can be crawled, the crawl now finishes with the
  `robotstxt_denied` [`finish_reason`](topics/stats.md) instead of `finished`, and an
  error is logged.
  ([#6164](https://github.com/scrapy/scrapy/issues/6164))
- [`urlparse_cached()`](topics/request-response.md) 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`](topics/request-response.md) and [`Response`](topics/request-response.md) objects.
  Built-in components now reuse URL parsing results more, which makes
  crawls faster.
  ([#8247](https://github.com/scrapy/scrapy/issues/8247))
- Added a [`proxy_headers`](topics/request-response.md) request meta key, to send headers to the
  proxy set in [`proxy`](topics/downloader-middleware.md), e.g. in the `CONNECT` request of HTTPS
  URLs.
  ([#3329](https://github.com/scrapy/scrapy/issues/3329), [#7888](https://github.com/scrapy/scrapy/issues/7888))
- Added
  [`UriUserInfoMiddleware`](topics/downloader-middleware.md),
  enabled by default, which removes the credentials from request URLs like
  `https://user:pass@example.com` and sets them as [`http_user`](topics/request-response.md)
  and [`http_pass`](topics/request-response.md), or as [`ftp_user`](topics/settings.md) and
  [`ftp_password`](topics/settings.md) for FTP URLs. As a result, [`Request.url`](topics/request-response.md) and [`Response.url`](topics/request-response.md)
  no longer include those credentials after that middleware.
  ([#669](https://github.com/scrapy/scrapy/issues/669), [#851](https://github.com/scrapy/scrapy/issues/851), [#1466](https://github.com/scrapy/scrapy/issues/1466), [#4474](https://github.com/scrapy/scrapy/issues/4474))
- Added an [`HTTPCACHE_SCOPE`](topics/downloader-middleware.md) setting, which allows sharing the HTTP
  cache across spiders and, with
  [`FilesystemCacheStorage`](topics/downloader-middleware.md), splitting it
  by request host instead of by spider.
  ([#5166](https://github.com/scrapy/scrapy/issues/5166), [#5175](https://github.com/scrapy/scrapy/issues/5175), [#7964](https://github.com/scrapy/scrapy/issues/7964))
- Added a [`LOG_ROOT_FORMATTER`](topics/logging.md) setting, which sets the formatter of
  the root log handler. Such formatters implement the new
  [`LogRootFormatterProtocol`](topics/logging.md), and the new
  [`LogRootFormatter`](topics/logging.md) is the default one, which you can also
  use in your own log handlers.
  [`LOG_COLOR`](topics/settings.md) also works with custom formatters.
  ([#8336](https://github.com/scrapy/scrapy/issues/8336))
- Added a [`CONNECTION_KEEPALIVE_TIMEOUT`](topics/settings.md) 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](https://github.com/scrapy/scrapy/issues/8342))
- Added [`Response.follow_redirect()`](topics/request-response.md), which returns a request that
  follows the `Location` header of the response.
  ([#8331](https://github.com/scrapy/scrapy/issues/8331))
- When [`DOWNLOAD_FAIL_ON_DATALOSS`](topics/settings.md) or the
  [`download_fail_on_dataloss`](topics/request-response.md) 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`](topics/download-handlers.md),
  with all built-in download handlers except
  [`FTPDownloadHandler`](topics/download-handlers.md).
  ([#3407](https://github.com/scrapy/scrapy/issues/3407), [#3492](https://github.com/scrapy/scrapy/issues/3492), [#8084](https://github.com/scrapy/scrapy/issues/8084), [#8464](https://github.com/scrapy/scrapy/issues/8464))
- [`HTTP11DownloadHandler`](topics/download-handlers.md)
  now supports proxies with an IPv6 address, proxies whose host name only
  resolves to IPv6 addresses, given an IPv6-capable
  [`TWISTED_DNS_RESOLVER`](topics/settings.md), and HTTPS requests to IPv6 addresses
  through a proxy.
  ([#6674](https://github.com/scrapy/scrapy/issues/6674), [#7090](https://github.com/scrapy/scrapy/issues/7090), [#8116](https://github.com/scrapy/scrapy/issues/8116), [#8343](https://github.com/scrapy/scrapy/issues/8343))
- When asyncio support is available and `aioboto3` is installed,
  [S3 feed storage](topics/feed-exports.md "S3") uploads files with it,
  instead of running `boto3` in a thread. Similarly, the [S3 storage
  of media pipelines](topics/media-pipeline.md "Amazon S3 storage") uses `aiobotocore`, when
  installed, instead of `botocore`.
  ([#3845](https://github.com/scrapy/scrapy/issues/3845), [#8330](https://github.com/scrapy/scrapy/issues/8330), [#8339](https://github.com/scrapy/scrapy/issues/8339))
- Added a [`CONCURRENT_CONNECTIONS_PER_HANDLER`](topics/settings.md) 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()`](https://docs.python.org/3/library/select.html#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](faq.md)).
  ([#2653](https://github.com/scrapy/scrapy/issues/2653), [#5024](https://github.com/scrapy/scrapy/issues/5024), [#5618](https://github.com/scrapy/scrapy/issues/5618), [#7932](https://github.com/scrapy/scrapy/issues/7932))
- Added a [`REDIRECT_HTTP_CODES`](topics/downloader-middleware.md) setting and a
  [`redirect_http_codes`](topics/downloader-middleware.md) request meta key, which set the response
  status codes whose `Location` header
  [`RedirectMiddleware`](topics/downloader-middleware.md) follows,
  e.g. to follow the `Location` header of 201 responses. Media pipelines
  with [`MEDIA_ALLOW_REDIRECTS`](topics/media-pipeline.md) enabled leave responses with those
  status codes to
  [`RedirectMiddleware`](topics/downloader-middleware.md).
  ([#1615](https://github.com/scrapy/scrapy/issues/1615), [#7801](https://github.com/scrapy/scrapy/issues/7801))
- [`HTTP11DownloadHandler`](topics/download-handlers.md) now
  supports `https://` proxy URLs for `https://` destination URLs.
  ([#5828](https://github.com/scrapy/scrapy/issues/5828), [#7776](https://github.com/scrapy/scrapy/issues/7776))
- When several requests for the same resource are sent concurrently,
  [`HttpCacheMiddleware`](topics/downloader-middleware.md) now
  downloads it only once, and, if the response is cached, serves it from the
  cache to the other requests.
  The new [`httpcache/wait`](topics/stats.md) stat counts the requests that waited for
  another one.
  ([#2744](https://github.com/scrapy/scrapy/issues/2744), [#7915](https://github.com/scrapy/scrapy/issues/7915))
- `XMLFeedSpider.parse_node()`, `CSVFeedSpider.parse_row()` and the
  *errback* of [`Rule`](topics/spiders.md) can now be defined as coroutine
  functions (`async def`) or asynchronous generator functions.
  ([#8392](https://github.com/scrapy/scrapy/issues/8392))
- `item_completed()` in subclasses of `MediaPipeline` can now be defined
  as a coroutine function (`async def`), and `stat_file()` in
  [custom media storages](topics/media-pipeline.md "Custom storage") can now await
  [`asyncio`](https://docs.python.org/3/library/asyncio.html#module-asyncio) code.
  ([#8413](https://github.com/scrapy/scrapy/issues/8413))
- [`BaseSettings.getlist()`](topics/api.md) 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](https://github.com/scrapy/scrapy/issues/8416))
- Added a [`RESPONSE_ROUGH_SIZE`](topics/settings.md) setting, the
  [`ExecutionEngine.response_active_size`](topics/api.md) attribute, and
  the [`request_backout_seconds/concurrency`](topics/stats.md),
  [`request_backout_seconds/response_max_active_size`](topics/stats.md) and
  [`request_backout_seconds/total`](topics/stats.md) stats. See
  [Identifying crawl bottlenecks](topics/practices.md).
  ([#5302](https://github.com/scrapy/scrapy/issues/5302), [#6206](https://github.com/scrapy/scrapy/issues/6206), [#6430](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/8393))
- With [parsel](https://github.com/scrapy/parsel) 1.12.0+, [`Selector`](topics/selectors.md) 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](https://github.com/scrapy/scrapy/issues/5906), [#8195](https://github.com/scrapy/scrapy/issues/8195), [#8222](https://github.com/scrapy/scrapy/issues/8222), [#8393](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/2977), [#8245](https://github.com/scrapy/scrapy/issues/8245))
- The reactor settings [`DNSCACHE_ENABLED`](topics/settings.md), [`DNSCACHE_SIZE`](topics/settings.md),
  [`DNS_TIMEOUT`](topics/settings.md), [`REACTOR_THREADPOOL_MAXSIZE`](topics/settings.md) and
  [`TWISTED_DNS_RESOLVER`](topics/settings.md) can now be [set from a spider](topics/settings.md "2. Spider settings") when using [`CrawlerProcess`](topics/api.md) or
  [`AsyncCrawlerProcess`](topics/api.md). When [running multiple
  spiders in the same process](topics/practices.md "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`](topics/api.md) of that first spider in its
  `from_crawler()` method.
  ([#5988](https://github.com/scrapy/scrapy/issues/5988), [#7923](https://github.com/scrapy/scrapy/issues/7923))
- The [`runspider`](topics/commands.md) command now accepts file paths without an
  extension, such as the ones of Bash process substitution
  (`scrapy runspider <(…)`).
  ([#4827](https://github.com/scrapy/scrapy/issues/4827), [#8036](https://github.com/scrapy/scrapy/issues/8036))
- Items are now processed by tasks started on demand, instead of by a fixed
  number of tasks, one per [`CONCURRENT_ITEMS`](topics/settings.md), started for every
  response, so a high [`CONCURRENT_ITEMS`](topics/settings.md) value no longer slows down
  crawls. [`CONCURRENT_ITEMS`](topics/settings.md) values lower than `1` now work as
  `1`.
  ([#5182](https://github.com/scrapy/scrapy/issues/5182), [#7959](https://github.com/scrapy/scrapy/issues/7959))
- Exceptions raised while exporting an item to a [feed](topics/feed-exports.md) now include the item in a note.
  ([#2775](https://github.com/scrapy/scrapy/issues/2775), [#8191](https://github.com/scrapy/scrapy/issues/8191))
- When a [`TextResponse`](topics/request-response.md) is created with a `str`
  body and a UTF-8 encoding, that body is now reused as
  [`text`](topics/request-response.md) instead of being decoded again.
  ([#8220](https://github.com/scrapy/scrapy/issues/8220))
- Improved the performance of link extraction with
  [`LxmlLinkExtractor`](topics/link-extractors.md).
  ([#8126](https://github.com/scrapy/scrapy/issues/8126))
- Compressed response bodies of 8 KiB or more are now decompressed in a
  thread, so that other responses can be processed meanwhile.
  ([#3751](https://github.com/scrapy/scrapy/issues/3751), [#8153](https://github.com/scrapy/scrapy/issues/8153))
- The Scrapy version and the versions of [`LOG_VERSIONS`](topics/settings.md) are now
  logged when each crawler is set up, after [add-ons](topics/addons.md)
  and spider settings are applied, so that they can change
  [`BOT_NAME`](topics/settings.md) and [`LOG_VERSIONS`](topics/settings.md). They are now also logged
  when using [`CrawlerRunner`](topics/api.md) or
  [`AsyncCrawlerRunner`](topics/api.md). Add-ons can now [log
  the versions of their dependencies](topics/addons.md).
  ([#8246](https://github.com/scrapy/scrapy/issues/8246))
- `scrapy.pipelines.files.S3FilesStore` now supports any header that
  [botocore](https://github.com/boto/botocore) supports for uploads, and [media pipelines](topics/media-pipeline.md) now document how to set custom headers for files
  uploaded to Amazon S3.
  ([#4788](https://github.com/scrapy/scrapy/issues/4788), [#4813](https://github.com/scrapy/scrapy/issues/4813), [#8171](https://github.com/scrapy/scrapy/issues/8171))
- [`H2DownloadHandler`](topics/download-handlers.md) 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](https://github.com/scrapy/scrapy/issues/4919), [#7944](https://github.com/scrapy/scrapy/issues/7944))
- [`H2DownloadHandler`](topics/download-handlers.md) now
  supports [`DOWNLOAD_FAIL_ON_DATALOSS`](topics/settings.md) and the
  [`download_fail_on_dataloss`](topics/request-response.md) 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`](topics/download-handlers.md) instead of
  [`DownloadFailedError`](topics/download-handlers.md). HTTP/2 data loss is now also
  detected by
  [`HttpxDownloadHandler`](topics/download-handlers.md).
  ([#5048](https://github.com/scrapy/scrapy/issues/5048), [#7989](https://github.com/scrapy/scrapy/issues/7989))
- Spiders that request the `robots.txt` file of a host, like
  [`SitemapSpider`](topics/spiders.md), no longer download it twice when
  [`ROBOTSTXT_OBEY`](topics/settings.md) is `True`:
  [`RobotsTxtMiddleware`](topics/downloader-middleware.md) 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](https://github.com/scrapy/scrapy/issues/3967), [#8069](https://github.com/scrapy/scrapy/issues/8069))
- Requests that set the [`download_maxsize`](topics/settings.md) request meta key but not
  [`download_warnsize`](topics/settings.md) no longer log a warning based on
  [`DOWNLOAD_WARNSIZE`](topics/settings.md).
  ([#8213](https://github.com/scrapy/scrapy/issues/8213))
- [`AiohttpDownloadHandler`](topics/download-handlers.md)
  is now [lazy](topics/download-handlers.md "Lazy instantiation of download handlers").
  ([#8346](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/8345))
- [`call_later()`](topics/asyncio.md) and the processing of the output
  of spider callbacks now run in the [`contextvars`](https://docs.python.org/3/library/contextvars.html#module-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](https://github.com/scrapy/scrapy/issues/8347))
- Improved the performance of `scrapy.utils.python.binary_is_text()`,
  which is used to pick the class of responses.
  ([#8362](https://github.com/scrapy/scrapy/issues/8362))
- [`CookiesMiddleware`](topics/cookies.md) 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](https://github.com/scrapy/scrapy/issues/5431), [#8431](https://github.com/scrapy/scrapy/issues/8431))
- Improved the performance of [feed exports](topics/feed-exports.md),
  especially for items with scalar field values.
  ([#8461](https://github.com/scrapy/scrapy/issues/8461))
- Improved the performance of [`StatsCollector`](topics/stats.md)
  method calls.
  ([#8243](https://github.com/scrapy/scrapy/issues/8243))
- Other code refactoring and improvements.
  ([#8262](https://github.com/scrapy/scrapy/issues/8262), [#8263](https://github.com/scrapy/scrapy/issues/8263), [#8295](https://github.com/scrapy/scrapy/issues/8295), [#8313](https://github.com/scrapy/scrapy/issues/8313), [#8323](https://github.com/scrapy/scrapy/issues/8323), [#8335](https://github.com/scrapy/scrapy/issues/8335),
  [#8353](https://github.com/scrapy/scrapy/issues/8353), [#8365](https://github.com/scrapy/scrapy/issues/8365), [#8385](https://github.com/scrapy/scrapy/issues/8385), [#8391](https://github.com/scrapy/scrapy/issues/8391), [#8415](https://github.com/scrapy/scrapy/issues/8415))

### Bug fixes

- [`FTPDownloadHandler`](topics/download-handlers.md) now raises
  [`DownloadFailedError`](topics/download-handlers.md) when the server drops the
  connection, so that those downloads are retried.
  ([#1511](https://github.com/scrapy/scrapy/issues/1511), [#8206](https://github.com/scrapy/scrapy/issues/8206))
- [`FilesPipeline`](topics/media-pipeline.md) now treats responses with
  the 201 status code as successful downloads.
  ([#8349](https://github.com/scrapy/scrapy/issues/8349))
- The `Cookie` header now lists cookies with the same path length from
  oldest to newest, as [**RFC 6265 Section 5.4**](https://datatracker.ietf.org/doc/html/rfc6265.html#section-5.4) requires.
  ([#5431](https://github.com/scrapy/scrapy/issues/5431), [#8321](https://github.com/scrapy/scrapy/issues/8321))
- The [`runspider`](topics/commands.md) command now runs the given file even if its name
  matches that of an already imported module, e.g. `json.py`.
  ([#8036](https://github.com/scrapy/scrapy/issues/8036), [#8463](https://github.com/scrapy/scrapy/issues/8463))
- The [`check`](topics/commands.md) command now reports errors that prevent a spider
  from crawling, e.g. errors raised while creating the spider, instead of
  silently ignoring them.
  ([#3716](https://github.com/scrapy/scrapy/issues/3716), [#7991](https://github.com/scrapy/scrapy/issues/7991))
- [`Request.from_curl()`](topics/request-response.md) 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()`](topics/request-response.md) 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](https://github.com/scrapy/scrapy/issues/8131), [#8138](https://github.com/scrapy/scrapy/issues/8138), [#8148](https://github.com/scrapy/scrapy/issues/8148), [#8267](https://github.com/scrapy/scrapy/issues/8267), [#8291](https://github.com/scrapy/scrapy/issues/8291), [#8292](https://github.com/scrapy/scrapy/issues/8292))
- `Headers.to_tuple_list()` no longer raises `UnicodeDecodeError`;
  bytes that cannot be decoded are replaced with U+FFFD.
  ([#2592](https://github.com/scrapy/scrapy/issues/2592), [#2637](https://github.com/scrapy/scrapy/issues/2637), [#8192](https://github.com/scrapy/scrapy/issues/8192))
- [`copy.copy()`](https://docs.python.org/3/library/copy.html#copy.copy) on an [`Item`](topics/items.md) now returns a shallow copy,
  like [`Item.copy()`](topics/items.md). 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](https://github.com/scrapy/scrapy/issues/8172))
- Calling `exit()` or `quit()` in the [telnet console](topics/telnetconsole.md) now closes the connection, instead of logging an
  unhandled error.
  ([#3853](https://github.com/scrapy/scrapy/issues/3853), [#8065](https://github.com/scrapy/scrapy/issues/8065))
- An exception raised while building the [`SCHEDULER`](topics/settings.md) is now
  reported as is, instead of being followed by a
  `RuntimeError` about an unassigned engine slot.
  ([#8169](https://github.com/scrapy/scrapy/issues/8169))
- The `lastseen` field of the representation of a downloader slot, e.g.
  in the [telnet console](topics/telnetconsole.md), now shows the
  monotonic timestamp of the last activity instead of a meaningless date.
  ([#8182](https://github.com/scrapy/scrapy/issues/8182))
- [`SitemapSpider`](topics/spiders.md) now resolves relative and
  protocol-relative URLs in sitemaps against the sitemap URL.
  ([#965](https://github.com/scrapy/scrapy/issues/965), [#8210](https://github.com/scrapy/scrapy/issues/8210))
- [`CrawlSpider`](topics/spiders.md) now follows the links of a response
  also when the callback of the matching rule raises an exception.
  ([#4108](https://github.com/scrapy/scrapy/issues/4108), [#8200](https://github.com/scrapy/scrapy/issues/8200))
- A [feed](topics/feed-exports.md) 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](https://github.com/scrapy/scrapy/issues/2089), [#8205](https://github.com/scrapy/scrapy/issues/8205))
- Fixed the file modification times that
  [`FilesPipeline`](topics/media-pipeline.md) reads from Amazon S3, Google
  Cloud Storage and FTP storages to apply [`FILES_EXPIRES`](topics/media-pipeline.md). S3 and
  Google Cloud Storage times were off by the UTC offset of the local time
  zone, and FTP times were misread.
  ([#8186](https://github.com/scrapy/scrapy/issues/8186), [#8196](https://github.com/scrapy/scrapy/issues/8196))
- Lines of a callback docstring that start with `@` but do not name a
  registered [contract](topics/contracts.md), e.g. a decorator in a code
  example, are now ignored, instead of raising `KeyError` or making the
  [`check`](topics/commands.md) command treat the callback as having contracts. As a
  result, a misspelled contract name is also ignored.
  ([#8226](https://github.com/scrapy/scrapy/issues/8226))
- The [`bench`](topics/commands.md) command now listens on a random free port, instead of
  failing when port 8998 is in use.
  ([#8230](https://github.com/scrapy/scrapy/issues/8230))
- [`CONCURRENT_REQUESTS_PER_DOMAIN`](topics/settings.md) and the `concurrency` key of
  [`DOWNLOAD_SLOTS`](topics/settings.md) are now enforced when using asyncio with no
  download delay.
  ([#8256](https://github.com/scrapy/scrapy/issues/8256), [#8257](https://github.com/scrapy/scrapy/issues/8257))
- [`SitemapSpider`](topics/spiders.md) now detects XML sitemaps also in
  responses that are not [`XmlResponse`](topics/request-response.md) objects, e.g.
  from third-party download handlers, based on their headers, URL and body.
  ([#6362](https://github.com/scrapy/scrapy/issues/6362), [#7904](https://github.com/scrapy/scrapy/issues/7904))
- Fixed the handling of headers that are not valid UTF-8 or ASCII in some
  download handlers:
  - [`HttpxDownloadHandler`](topics/download-handlers.md)
    no longer fails on non-ASCII request headers.
  - [`AiohttpDownloadHandler`](topics/download-handlers.md)
    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`](topics/download-handlers.md) no
    longer fails, or hangs, on request or response headers that are not
    valid UTF-8.

  ([#8265](https://github.com/scrapy/scrapy/issues/8265))
- `Headers.get()` now returns the given default value for a header set to
  `None`.
  ([#8268](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/8266), [#8271](https://github.com/scrapy/scrapy/issues/8271))
- Changing the header values in the output of [`Request.to_dict()`](topics/request-response.md) or [`Response.to_dict()`](topics/request-response.md) no longer changes the original request or
  response.
  ([#8269](https://github.com/scrapy/scrapy/issues/8269))
- [`HTTP11DownloadHandler`](topics/download-handlers.md) now
  closes the proxy connection of an HTTPS request that times out, or is
  otherwise cancelled, before the proxy has established the tunnel.
  ([#3614](https://github.com/scrapy/scrapy/issues/3614), [#7810](https://github.com/scrapy/scrapy/issues/7810))
- [`RedirectMiddleware`](topics/downloader-middleware.md) no
  longer copies the fragment of the original URL into the redirect URL when
  the `Location` header ends with an empty fragment (`#`).
  ([#8100](https://github.com/scrapy/scrapy/issues/8100))
- When using a [job directory](topics/jobs.md), the default scheduler now pops
  requests by [`priority`](topics/request-response.md) 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`](topics/settings.md) classes need to implement the
  new [`next_priority()`](topics/scheduler.md) method to
  get this behavior. [`PriorityQueueProtocol`](topics/scheduler.md)
  documents the interface of priority queue classes.
  ([#3666](https://github.com/scrapy/scrapy/issues/3666), [#8237](https://github.com/scrapy/scrapy/issues/8237))
- When resuming a crawl from a [job directory](topics/jobs.md), 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](https://github.com/scrapy/scrapy/issues/5153), [#7650](https://github.com/scrapy/scrapy/issues/7650), [#7656](https://github.com/scrapy/scrapy/issues/7656))
- [Item exporters](topics/exporters.md) now serialize nested items, and
  lists of them, using the serializers declared in their own fields.
  ([#3888](https://github.com/scrapy/scrapy/issues/3888), [#3890](https://github.com/scrapy/scrapy/issues/3890), [#8057](https://github.com/scrapy/scrapy/issues/8057))
- Fixed [`AsyncioLoopingCall`](topics/asyncio.md) 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`](topics/extensions.md) while it was still producing items.
  ([#8294](https://github.com/scrapy/scrapy/issues/8294))
- The [RobotFileParser](topics/downloader-middleware.md) 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](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7201), [#8324](https://github.com/scrapy/scrapy/issues/8324), [#8325](https://github.com/scrapy/scrapy/issues/8325))
- Stopping a crawl while an item yielded from [`start()`](topics/spiders.md) is
  going through the [item pipelines](topics/item-pipeline.md) no longer
  hangs.
  ([#8348](https://github.com/scrapy/scrapy/issues/8348))
- [`H2DownloadHandler`](topics/download-handlers.md) 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](https://github.com/scrapy/scrapy/issues/8332))
- Fixed [`ScrapyPriorityQueue`](topics/scheduler.md), which the default
  [`DownloaderAwarePriorityQueue`](topics/scheduler.md) 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](https://github.com/scrapy/scrapy/issues/7837))
- The [telnet console](topics/telnetconsole.md), 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](https://github.com/scrapy/scrapy/issues/8356))
- Fixed [`RobotsTxtMiddleware`](topics/downloader-middleware.md)
  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](https://github.com/scrapy/scrapy/issues/8297), [#8386](https://github.com/scrapy/scrapy/issues/8386))
- [`SitemapSpider`](topics/spiders.md) now only treats links with
  `rel="alternate"` as alternate links, instead of any link, e.g.
  canonical ones, both when
  [`sitemap_alternate_links`](topics/spiders.md) is enabled
  and in the entries passed to
  [`sitemap_filter()`](topics/spiders.md).
  ([#8390](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/8167), [#8377](https://github.com/scrapy/scrapy/issues/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`](topics/settings.md).
  ([#8315](https://github.com/scrapy/scrapy/issues/8315), [#8355](https://github.com/scrapy/scrapy/issues/8355))
- The reactorless [`shell`](topics/commands.md) now waits for the engine to start before
  letting you use it.
  ([#8168](https://github.com/scrapy/scrapy/issues/8168))
- On Windows,
  [`AiohttpDownloadHandler`](topics/download-handlers.md)
  no longer connects to the wrong port in rare cases.
  ([#8382](https://github.com/scrapy/scrapy/issues/8382))
- The Scrapy [`shell`](topics/commands.md) no longer uses [ptpython](https://github.com/prompt-toolkit/ptpython) on Windows when the
  standard output is not a console, which [ptpython](https://github.com/prompt-toolkit/ptpython) does not support.
  ([#8367](https://github.com/scrapy/scrapy/issues/8367))

### Documentation

- Documented [how blocking code in callbacks and other components
  slows down downloads](topics/optimize.md "Keeping the event loop free") and inflates their
  [`download_latency`](topics/request-response.md).
  ([#3197](https://github.com/scrapy/scrapy/issues/3197), [#8160](https://github.com/scrapy/scrapy/issues/8160))
- Documented [how to change concurrency and delays from the telnet
  console](topics/telnetconsole.md "Change concurrency and delays") on a running crawl.
  ([#4196](https://github.com/scrapy/scrapy/issues/4196), [#8164](https://github.com/scrapy/scrapy/issues/8164))
- Documented that the `open_spider()` and `close_spider()` methods of
  [item pipelines](topics/item-pipeline.md) run concurrently, and only
  `process_item()` follows the [`ITEM_PIPELINES`](topics/settings.md) order.
  ([#2645](https://github.com/scrapy/scrapy/issues/2645), [#8158](https://github.com/scrapy/scrapy/issues/8158))
- Documented [how to set up a development environment](contributing.md "Setting up a development environment") to
  contribute to Scrapy.
  ([#4451](https://github.com/scrapy/scrapy/issues/4451), [#8165](https://github.com/scrapy/scrapy/issues/8165))
- Moved the release notes of Scrapy 2.13 and older into separate pages per
  major version.
  ([#8150](https://github.com/scrapy/scrapy/issues/8150))
- Documented [how to extract clean content and parse values](topics/extraction.md), [how to sign requests with OAuth](topics/downloader-middleware.md "Signing requests with OAuth"), how to
  deduplicate repeated query string parameters in [request fingerprints](topics/request-response.md "Writing your own request fingerprinter"), and that retried status codes should also
  be in [`HTTPCACHE_IGNORE_HTTP_CODES`](topics/downloader-middleware.md).
  ([#40](https://github.com/scrapy/scrapy/issues/40), [#1113](https://github.com/scrapy/scrapy/issues/1113), [#2297](https://github.com/scrapy/scrapy/issues/2297), [#8190](https://github.com/scrapy/scrapy/issues/8190), [#8202](https://github.com/scrapy/scrapy/issues/8202), [#8208](https://github.com/scrapy/scrapy/issues/8208),
  [#8209](https://github.com/scrapy/scrapy/issues/8209))
- Improved the API reference of [`SitemapSpider`](topics/spiders.md),
  [`XMLFeedSpider`](topics/spiders.md) and
  [`CSVFeedSpider`](topics/spiders.md).
  ([#8229](https://github.com/scrapy/scrapy/issues/8229), [#8239](https://github.com/scrapy/scrapy/issues/8239))
- Documented the order of the [`spider_opened`](topics/signals.md),
  [`engine_started`](topics/signals.md), [`spider_closed`](topics/signals.md) and
  [`engine_stopped`](topics/signals.md) signals.
  ([#1523](https://github.com/scrapy/scrapy/issues/1523), [#8101](https://github.com/scrapy/scrapy/issues/8101))
- Documented that the [`JOBDIR`](topics/settings.md) and [`HTTPCACHE_DIR`](topics/downloader-middleware.md)
  directories must be protected from [write access by untrusted
  parties](topics/security.md "Local data directories").
  ([#8252](https://github.com/scrapy/scrapy/issues/8252))
- Documented [how to write custom feed storage backends](topics/feed-exports.md "Custom storage backends") and the [built-in feed storage backend
  classes](topics/feed-exports.md "Storage backend classes").
  ([#7800](https://github.com/scrapy/scrapy/issues/7800))
- Added an introduction video to the [page about coding agents](topics/agents.md).
  ([#8253](https://github.com/scrapy/scrapy/issues/8253))
- [`CrawlSpider`](topics/spiders.md) and [`Rule`](topics/spiders.md) are
  now documented through their docstrings, and the documentation now
  recommends [`Spider`](topics/spiders.md) over
  [`CrawlSpider`](topics/spiders.md) for crawls that do not fit its
  declarative rules.
  ([#7025](https://github.com/scrapy/scrapy/issues/7025), [#8240](https://github.com/scrapy/scrapy/issues/8240))
- Documented the
  [`open_spider_async()`](topics/api.md),
  [`start_async()`](topics/api.md),
  [`close_spider_async()`](topics/api.md) and
  [`stop_async()`](topics/api.md) methods of the
  execution engine.
  ([#6164](https://github.com/scrapy/scrapy/issues/6164), [#8462](https://github.com/scrapy/scrapy/issues/8462))
- Documented [how to write asyncio code that also supports older Scrapy
  versions](topics/asyncio.md "Supporting older Scrapy versions"), and the documentation now recommends
  [`asyncio.to_thread()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread) to call blocking code from [coroutines](topics/coroutines.md).
  ([#7956](https://github.com/scrapy/scrapy/issues/7956), [#8454](https://github.com/scrapy/scrapy/issues/8454))
- Reviewed the documentation of [`Spider`](topics/spiders.md), which now covers
  all its attributes, including [`state`](topics/spiders.md).
  ([#7025](https://github.com/scrapy/scrapy/issues/7025), [#7811](https://github.com/scrapy/scrapy/issues/7811))
- Updated the [installation guide](intro/install.md), and documented
  [what to do when installing a dependency fails](intro/install.md "Installation fails while building a dependency").
  ([#5308](https://github.com/scrapy/scrapy/issues/5308), [#7878](https://github.com/scrapy/scrapy/issues/7878))
- The [tutorial](intro/tutorial.md) now shows how to crawl
  `quotes.toscrape.com` faster with [`DOWNLOAD_SLOTS`](topics/settings.md).
  ([#8334](https://github.com/scrapy/scrapy/issues/8334))
- Documented [`HttpError`](topics/spider-middleware.md), the
  IPv6 support of the built-in [download handlers](topics/download-handlers.md), the `bootstrap_failed` attribute of crawler
  processes, and where exceptions that interrupt a crawl started from a
  [script](topics/practices.md "Run Scrapy from a script") reach your code.
  ([#8338](https://github.com/scrapy/scrapy/issues/8338), [#8340](https://github.com/scrapy/scrapy/issues/8340), [#8344](https://github.com/scrapy/scrapy/issues/8344))
- Added a [page about getting help](intro/getting-help.md).
  ([#3688](https://github.com/scrapy/scrapy/issues/3688))
- Documented that high values of [`CONCURRENT_REQUESTS`](topics/settings.md) may exceed
  the limit of open file descriptors that the operating system sets, and how
  to raise that limit.
  ([#5259](https://github.com/scrapy/scrapy/issues/5259), [#5272](https://github.com/scrapy/scrapy/issues/5272))
- Other documentation improvements and fixes.
  ([#5859](https://github.com/scrapy/scrapy/issues/5859), [#7114](https://github.com/scrapy/scrapy/issues/7114), [#8151](https://github.com/scrapy/scrapy/issues/8151), [#8161](https://github.com/scrapy/scrapy/issues/8161), [#8314](https://github.com/scrapy/scrapy/issues/8314), [#8403](https://github.com/scrapy/scrapy/issues/8403),
  [#8404](https://github.com/scrapy/scrapy/issues/8404), [#8436](https://github.com/scrapy/scrapy/issues/8436), [#8453](https://github.com/scrapy/scrapy/issues/8453))

### Quality assurance

- Improved and fixed type hints.
  ([#7811](https://github.com/scrapy/scrapy/issues/7811), [#8078](https://github.com/scrapy/scrapy/issues/8078), [#8183](https://github.com/scrapy/scrapy/issues/8183), [#8311](https://github.com/scrapy/scrapy/issues/8311), [#8333](https://github.com/scrapy/scrapy/issues/8333), [#8440](https://github.com/scrapy/scrapy/issues/8440))
- Improved CodSpeed benchmarks.
  ([#8227](https://github.com/scrapy/scrapy/issues/8227), [#8234](https://github.com/scrapy/scrapy/issues/8234), [#8456](https://github.com/scrapy/scrapy/issues/8456))
- Improved the documentation build and the contributor tooling, including
  an `AGENTS.md` file for coding agents.
  ([#8011](https://github.com/scrapy/scrapy/issues/8011), [#8154](https://github.com/scrapy/scrapy/issues/8154), [#8157](https://github.com/scrapy/scrapy/issues/8157), [#8188](https://github.com/scrapy/scrapy/issues/8188), [#8212](https://github.com/scrapy/scrapy/issues/8212), [#8214](https://github.com/scrapy/scrapy/issues/8214),
  [#8216](https://github.com/scrapy/scrapy/issues/8216), [#8219](https://github.com/scrapy/scrapy/issues/8219), [#8238](https://github.com/scrapy/scrapy/issues/8238), [#8251](https://github.com/scrapy/scrapy/issues/8251), [#8364](https://github.com/scrapy/scrapy/issues/8364), [#8384](https://github.com/scrapy/scrapy/issues/8384),
  [#8409](https://github.com/scrapy/scrapy/issues/8409), [#8411](https://github.com/scrapy/scrapy/issues/8411))
- CI and test improvements and fixes.
  ([#6141](https://github.com/scrapy/scrapy/issues/6141), [#7949](https://github.com/scrapy/scrapy/issues/7949), [#8127](https://github.com/scrapy/scrapy/issues/8127), [#8155](https://github.com/scrapy/scrapy/issues/8155), [#8156](https://github.com/scrapy/scrapy/issues/8156), [#8194](https://github.com/scrapy/scrapy/issues/8194),
  [#8223](https://github.com/scrapy/scrapy/issues/8223), [#8228](https://github.com/scrapy/scrapy/issues/8228), [#8231](https://github.com/scrapy/scrapy/issues/8231), [#8232](https://github.com/scrapy/scrapy/issues/8232), [#8233](https://github.com/scrapy/scrapy/issues/8233), [#8235](https://github.com/scrapy/scrapy/issues/8235),
  [#8236](https://github.com/scrapy/scrapy/issues/8236), [#8258](https://github.com/scrapy/scrapy/issues/8258), [#8273](https://github.com/scrapy/scrapy/issues/8273), [#8274](https://github.com/scrapy/scrapy/issues/8274), [#8275](https://github.com/scrapy/scrapy/issues/8275), [#8276](https://github.com/scrapy/scrapy/issues/8276),
  [#8277](https://github.com/scrapy/scrapy/issues/8277), [#8278](https://github.com/scrapy/scrapy/issues/8278), [#8279](https://github.com/scrapy/scrapy/issues/8279), [#8280](https://github.com/scrapy/scrapy/issues/8280), [#8281](https://github.com/scrapy/scrapy/issues/8281), [#8286](https://github.com/scrapy/scrapy/issues/8286),
  [#8300](https://github.com/scrapy/scrapy/issues/8300), [#8301](https://github.com/scrapy/scrapy/issues/8301), [#8311](https://github.com/scrapy/scrapy/issues/8311), [#8314](https://github.com/scrapy/scrapy/issues/8314), [#8317](https://github.com/scrapy/scrapy/issues/8317), [#8320](https://github.com/scrapy/scrapy/issues/8320),
  [#8351](https://github.com/scrapy/scrapy/issues/8351), [#8359](https://github.com/scrapy/scrapy/issues/8359), [#8360](https://github.com/scrapy/scrapy/issues/8360), [#8361](https://github.com/scrapy/scrapy/issues/8361), [#8372](https://github.com/scrapy/scrapy/issues/8372), [#8374](https://github.com/scrapy/scrapy/issues/8374),
  [#8375](https://github.com/scrapy/scrapy/issues/8375), [#8381](https://github.com/scrapy/scrapy/issues/8381), [#8387](https://github.com/scrapy/scrapy/issues/8387), [#8388](https://github.com/scrapy/scrapy/issues/8388), [#8389](https://github.com/scrapy/scrapy/issues/8389), [#8406](https://github.com/scrapy/scrapy/issues/8406),
  [#8412](https://github.com/scrapy/scrapy/issues/8412), [#8423](https://github.com/scrapy/scrapy/issues/8423), [#8444](https://github.com/scrapy/scrapy/issues/8444))

## 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](topics/agents.md "Using the MCP server")
- Experimental `aiohttp`-based download handler (now the default when
  running without a reactor)

### Modified requirements

- Added support for Python 3.15.
  ([#7511](https://github.com/scrapy/scrapy/issues/7511))
- New dependencies:
  - [aiohttp](https://docs.aiohttp.org/en/stable/) >= 3.13.3
  - [charset-normalizer](https://charset-normalizer.readthedocs.io/en/latest/) >= 3.4.0
  - [platformdirs](https://platformdirs.readthedocs.io/en/latest/) >= 2.0.0

  ([#7866](https://github.com/scrapy/scrapy/issues/7866), [#8054](https://github.com/scrapy/scrapy/issues/8054))

### Backward-incompatible changes

- When running [without a Twisted reactor](topics/asyncio.md "Using Scrapy without a Twisted reactor"),
  i.e. with [`TWISTED_REACTOR_ENABLED`](topics/settings.md) set to `False`, the default
  download handler for `http` and `https` is now
  [`AiohttpDownloadHandler`](topics/download-handlers.md)
  instead of
  [`HttpxDownloadHandler`](topics/download-handlers.md). You
  can configure
  [`HttpxDownloadHandler`](topics/download-handlers.md) in
  the [`DOWNLOAD_HANDLERS`](topics/settings.md) setting if you want.
  ([#8118](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7933))

### Deprecations

- The `RANDOMIZE_DOWNLOAD_DELAY` setting is deprecated. Use the new
  [`DOWNLOAD_DELAY_JITTER`](topics/settings.md) setting instead. Similarly, the
  `randomize_delay` key of the [`DOWNLOAD_SLOTS`](topics/settings.md) 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`](topics/settings.md) setting.
  ([#7881](https://github.com/scrapy/scrapy/issues/7881))
- The `install_root_handler` parameter of
  [`configure_logging()`](topics/logging.md),
  [`CrawlerProcess`](topics/api.md) and
  [`AsyncCrawlerProcess`](topics/api.md) is deprecated. Use the new
  [`LOG_INSTALL_ROOT_HANDLER`](topics/settings.md) setting instead.
  ([#4793](https://github.com/scrapy/scrapy/issues/4793), [#8041](https://github.com/scrapy/scrapy/issues/8041))
- The `scrapy.dupefilters.RFPDupeFilter.fingerprints` attribute is
  deprecated. Overriding
  `scrapy.dupefilters.RFPDupeFilter.request_fingerprint()` is deprecated
  as well; set the [`REQUEST_FINGERPRINTER_CLASS`](topics/request-response.md) setting instead.
  ([#5517](https://github.com/scrapy/scrapy/issues/5517), [#7943](https://github.com/scrapy/scrapy/issues/7943))
- Overriding the `add_pre_hook()` or `add_post_hook()` methods of
  [`Contract`](topics/contracts.md) is deprecated. Define
  `pre_process()` or `post_process()` instead.
  ([#6681](https://github.com/scrapy/scrapy/issues/6681), [#7886](https://github.com/scrapy/scrapy/issues/7886))

### New features

- Added a [`RemoteControl`](topics/extensions.md)
  extension, enabled by default, which allows connecting to crawl processes
  via HTTP and running code inside them.
  ([#7866](https://github.com/scrapy/scrapy/issues/7866))
- Added an experimental HTTP download handler based on [aiohttp](https://docs.aiohttp.org/en/stable/),
  [`AiohttpDownloadHandler`](topics/download-handlers.md).
  ([#8118](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/845), [#7877](https://github.com/scrapy/scrapy/issues/7877))
- Added a [`DOWNLOAD_DELAY_JITTER`](topics/settings.md) setting, and a `jitter` key for
  [`DOWNLOAD_SLOTS`](topics/settings.md), which set the magnitude of the random variation
  applied to [`DOWNLOAD_DELAY`](topics/settings.md). They replace the
  `RANDOMIZE_DOWNLOAD_DELAY` setting and the `randomize_delay` key, which
  could only toggle a fixed ±50%.
  ([#7881](https://github.com/scrapy/scrapy/issues/7881))
- Added a [`LOG_COLOR`](topics/settings.md) setting, which colorizes log output by log
  level when logging to a terminal. It needs the new [color](intro/install.md "Optional extras")
  extra.
  ([#8091](https://github.com/scrapy/scrapy/issues/8091))
- The encoding of a response that doesn’t declare one is now detected with
  [charset-normalizer](https://charset-normalizer.readthedocs.io/en/latest/) when the response body is neither ASCII nor UTF-8,
  instead of always falling back to `cp1252`.
  ([#3135](https://github.com/scrapy/scrapy/issues/3135), [#8054](https://github.com/scrapy/scrapy/issues/8054))
- Added a [`LOG_INSTALL_ROOT_HANDLER`](topics/settings.md) 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](https://github.com/scrapy/scrapy/issues/4793), [#8041](https://github.com/scrapy/scrapy/issues/8041))
- [Contracts](topics/contracts.md) now support callbacks defined with
  `async def`, including asynchronous generators.
  ([#6681](https://github.com/scrapy/scrapy/issues/6681), [#7886](https://github.com/scrapy/scrapy/issues/7886))
- Added the [`MethodContract`](topics/contracts.md) (`@method`),
  [`BodyContract`](topics/contracts.md) (`@body`),
  [`HeaderContract`](topics/contracts.md) (`@header`) and
  [`CookieContract`](topics/contracts.md) (`@cookie`)
  contracts, which set the corresponding attributes of the sample request,
  and an `-a` option for the [`check`](topics/commands.md) command, to set spider
  arguments as in the [`crawl`](topics/commands.md) command.
  ([#1918](https://github.com/scrapy/scrapy/issues/1918), [#8053](https://github.com/scrapy/scrapy/issues/8053))
- Added [`Response.to_dict()`](topics/request-response.md),
  [`Response.from_dict()`](topics/request-response.md) and
  [`response_from_dict()`](topics/request-response.md), and used them in the
  built-in [HTTP cache storages](topics/downloader-middleware.md "Filesystem storage backend (default)"), which now
  restore cached responses of any response class, including those of
  third-party plugins, with all their attributes.
  ([#1450](https://github.com/scrapy/scrapy/issues/1450), [#7908](https://github.com/scrapy/scrapy/issues/7908))
- Cached responses now indicate when they were stored, through the new
  [`cache_timestamp`](topics/downloader-middleware.md) request meta key.
  ([#2221](https://github.com/scrapy/scrapy/issues/2221), [#8034](https://github.com/scrapy/scrapy/issues/8034))
- The `format` key of [`FEEDS`](topics/feed-exports.md) is now inferred from the file
  extension of the feed URI when not set, e.g. `json` for a URI ending in
  `.json`.
  ([#1158](https://github.com/scrapy/scrapy/issues/1158), [#8031](https://github.com/scrapy/scrapy/issues/8031))
- Added [`find_projects()`](topics/commands.md), which yields the root
  directory of every Scrapy project in a directory tree.
  ([#8024](https://github.com/scrapy/scrapy/issues/8024))
- Added a public [`scheduler`](topics/api.md)
  attribute to [`ExecutionEngine`](topics/api.md).
  ([#8099](https://github.com/scrapy/scrapy/issues/8099))
- [`StatsCollector`](topics/stats.md) objects now implement
  `__str__()`, which returns the pretty-printed stats.
  ([#2746](https://github.com/scrapy/scrapy/issues/2746))
- [`open_in_browser()`](topics/debug.md) now also supports
  responses that are neither HTML nor plain text, picking a file extension
  based on the `Content-Type` header.
  ([#3902](https://github.com/scrapy/scrapy/issues/3902), [#8067](https://github.com/scrapy/scrapy/issues/8067))
- The `-t`/`--template` option of the [`genspider`](topics/commands.md) command now
  also takes a path to a `.tmpl` file, so that a custom template can
  be used without setting [`TEMPLATES_DIR`](topics/settings.md).
  ([#8071](https://github.com/scrapy/scrapy/issues/8071))
- The `--pdb` command-line option now uses [ipdb](https://github.com/gotcha/ipdb) instead of [`pdb`](https://docs.python.org/3/library/pdb.html#module-pdb)
  when [ipdb](https://github.com/gotcha/ipdb) is installed.
  ([#4284](https://github.com/scrapy/scrapy/issues/4284), [#8052](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/8085))

### Improvements

- [`RFPDupeFilter`](topics/settings.md) now keeps request fingerprints
  as `bytes`, to reduce memory usage. The `requests.seen` file
  that it writes in the [job directory](topics/jobs.md) is now a binary file.
  ([#5517](https://github.com/scrapy/scrapy/issues/5517), [#7943](https://github.com/scrapy/scrapy/issues/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`](https://docs.twisted.org/en/stable/api/twisted.python.failure.Failure.html) object built anywhere in
  the process.
  ([#3552](https://github.com/scrapy/scrapy/issues/3552), [#8037](https://github.com/scrapy/scrapy/issues/8037))
- The Scrapy [`shell`](topics/commands.md) no longer prints the `DEBUG` messages of
  [parso](https://github.com/davidhalter/parso), an indirect dependency of IPython, when [`LOG_LEVEL`](topics/settings.md) is
  `DEBUG`.
  ([#8060](https://github.com/scrapy/scrapy/issues/8060))
- Other code refactoring and improvements.
  ([#8123](https://github.com/scrapy/scrapy/issues/8123))

### Bug fixes

- [`HTTP11DownloadHandler`](topics/download-handlers.md)
  now sets [`certificate`](topics/request-response.md) and
  [`ip_address`](topics/request-response.md) attributes even for responses
  without a body.
  ([#4466](https://github.com/scrapy/scrapy/issues/4466), [#8048](https://github.com/scrapy/scrapy/issues/8048))
- HTTP connection pool keys in
  [`HTTP11DownloadHandler`](topics/download-handlers.md) and
  [`H2DownloadHandler`](topics/download-handlers.md) now
  include the request bind address (see [`DOWNLOAD_BIND_ADDRESS`](topics/settings.md)), so
  that requests bound to different addresses no longer reuse each other’s
  pooled connections.
  ([#3565](https://github.com/scrapy/scrapy/issues/3565), [#8081](https://github.com/scrapy/scrapy/issues/8081))
- [`HttpCacheMiddleware`](topics/downloader-middleware.md) now
  updates the headers of a cached response, and stores it again, when a
  revalidation request gets a 304 response.
  ([#3778](https://github.com/scrapy/scrapy/issues/3778), [#8068](https://github.com/scrapy/scrapy/issues/8068))
- An exception raised in a spider callback that no
  [`process_spider_exception()`](topics/spider-middleware.md)
  method handles is now offered to each of those methods only once.
  ([#4729](https://github.com/scrapy/scrapy/issues/4729), [#7996](https://github.com/scrapy/scrapy/issues/7996))
- Defining [`allowed_domains`](topics/spiders.md) as a property no longer
  breaks the commands that match a URL to a spider, i.e. [`shell`](topics/commands.md),
  [`fetch`](topics/commands.md) and [`parse`](topics/commands.md). A property cannot be evaluated on
  a spider class, so it is now ignored, with a warning, instead of raising
  `TypeError`.
  ([#3119](https://github.com/scrapy/scrapy/issues/3119), [#8094](https://github.com/scrapy/scrapy/issues/8094))
- [`get_project_settings()`](topics/api.md) now adds the project
  directory to [`sys.path`](https://docs.python.org/3/library/sys.html#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](https://github.com/scrapy/scrapy/issues/4780), [#8042](https://github.com/scrapy/scrapy/issues/8042))
- `scrapy.utils.datatypes.LocalCache` no longer evicts the oldest item
  when updating an existing one.
  ([#8113](https://github.com/scrapy/scrapy/issues/8113))

### Documentation

- Added a page [about using Scrapy with coding agents](topics/agents.md),
  covering the official agent plugin and the Scrapy MCP server.
  ([#8120](https://github.com/scrapy/scrapy/issues/8120))
- Documented the request metadata keys that were missing from the
  [list of special keys](topics/request-response.md "Request.meta special keys"), and documented that keys
  whose name starts with an underscore are internal.
  ([#3585](https://github.com/scrapy/scrapy/issues/3585), [#5564](https://github.com/scrapy/scrapy/issues/5564), [#7933](https://github.com/scrapy/scrapy/issues/7933))
- Documented [how to write custom Scrapy commands](topics/commands.md "Custom project commands"),
  [how to write custom spider templates](topics/commands.md "Custom spider templates"), [how
  to access the response of a failed media download](topics/media-pipeline.md "Accessing the response of a failed download") and [how to set request headers
  for media pipeline requests](topics/media-pipeline.md "Setting request headers").
  ([#2046](https://github.com/scrapy/scrapy/issues/2046),
  [#2504](https://github.com/scrapy/scrapy/issues/2504),
  [#3056](https://github.com/scrapy/scrapy/issues/3056),
  [#6844](https://github.com/scrapy/scrapy/issues/6844),
  [#6904](https://github.com/scrapy/scrapy/issues/6904),
  [#8049](https://github.com/scrapy/scrapy/issues/8049),
  [#8056](https://github.com/scrapy/scrapy/issues/8056),
  [#8063](https://github.com/scrapy/scrapy/issues/8063))
- Documented how to subclass
  [`RedirectMiddleware`](topics/downloader-middleware.md) to
  allow or deny redirects based on the target URL, and how to set the
  priority of the requests that [`CrawlSpider`](topics/spiders.md)
  generates from its rules.
  ([#3613](https://github.com/scrapy/scrapy/issues/3613), [#4009](https://github.com/scrapy/scrapy/issues/4009), [#8061](https://github.com/scrapy/scrapy/issues/8061), [#8070](https://github.com/scrapy/scrapy/issues/8070))
- Documented that [`get_project_settings()`](topics/api.md)
  returns project settings only, that spiders [running concurrently in
  the same process](topics/practices.md "Running multiple spiders in the same process") get independent crawlers,
  middlewares and settings, and that Scrapy sets the `request` attribute
  of the [`Failure`](https://docs.twisted.org/en/stable/api/twisted.python.failure.Failure.html) objects that it passes to
  errbacks.
  ([#2378](https://github.com/scrapy/scrapy/issues/2378),
  [#4253](https://github.com/scrapy/scrapy/issues/4253),
  [#6408](https://github.com/scrapy/scrapy/issues/6408),
  [#7901](https://github.com/scrapy/scrapy/issues/7901),
  [#8051](https://github.com/scrapy/scrapy/issues/8051),
  [#8055](https://github.com/scrapy/scrapy/issues/8055))
- Documented [`ScrapyCommand`](topics/commands.md) and
  [`StatsCollector`](topics/stats.md).
  ([#6844](https://github.com/scrapy/scrapy/issues/6844), [#6904](https://github.com/scrapy/scrapy/issues/6904), [#8072](https://github.com/scrapy/scrapy/issues/8072))
- Improved the contents of `llms-full.txt` and Markdown versions of
  documentation pages.
  ([#8083](https://github.com/scrapy/scrapy/issues/8083),
  [#8087](https://github.com/scrapy/scrapy/issues/8087),
  [#8088](https://github.com/scrapy/scrapy/issues/8088),
  [#8089](https://github.com/scrapy/scrapy/issues/8089),
  [#8117](https://github.com/scrapy/scrapy/issues/8117),
  [#8119](https://github.com/scrapy/scrapy/issues/8119))

### Quality assurance

- Reached 100% test coverage.
  ([#8021](https://github.com/scrapy/scrapy/issues/8021))
- Improved and fixed type hints.
  ([#8017](https://github.com/scrapy/scrapy/issues/8017), [#8077](https://github.com/scrapy/scrapy/issues/8077), [#8102](https://github.com/scrapy/scrapy/issues/8102))
- Improved CodSpeed benchmarks.
  ([#8030](https://github.com/scrapy/scrapy/issues/8030), [#8080](https://github.com/scrapy/scrapy/issues/8080))
- CI and test improvements and fixes.
  ([#8027](https://github.com/scrapy/scrapy/issues/8027),
  [#8039](https://github.com/scrapy/scrapy/issues/8039),
  [#8059](https://github.com/scrapy/scrapy/issues/8059),
  [#8064](https://github.com/scrapy/scrapy/issues/8064),
  [#8073](https://github.com/scrapy/scrapy/issues/8073),
  [#8075](https://github.com/scrapy/scrapy/issues/8075),
  [#8076](https://github.com/scrapy/scrapy/issues/8076),
  [#8079](https://github.com/scrapy/scrapy/issues/8079),
  [#8092](https://github.com/scrapy/scrapy/issues/8092),
  [#8103](https://github.com/scrapy/scrapy/issues/8103),
  [#8115](https://github.com/scrapy/scrapy/issues/8115))

## Scrapy 2.18.0 (2026-08-20)

Highlights:

- `HttpxDownloadHandler` now uses [httpx2](https://httpx2.pydantic.dev/)
- The Twisted-based HTTP/2 download handler is no longer experimental
- `brotli` and Zstandard support are now always available, and [optional
  extras](intro/install.md "Optional extras") cover the rest of the optional features
- Late [`Crawler`](topics/api.md) attributes, such as
  [`stats`](topics/api.md), now raise `RuntimeError`
  instead of being `None` before the crawl starts
- Item exporters now export fields in declaration order
- New [`MetaCopyDetectionMiddleware`](topics/spider-middleware.md)
- New [optimization](topics/optimize.md) page and [built-in stats reference](topics/stats.md)

### Modified requirements

- `brotli` (`brotlicffi` on PyPy) and Zstandard support (the standard
  library [`compression.zstd`](https://docs.python.org/3/library/compression.zstd.html#module-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](https://github.com/scrapy/scrapy/issues/4698), [#6978](https://github.com/scrapy/scrapy/issues/6978), [#7083](https://github.com/scrapy/scrapy/issues/7083), [#7929](https://github.com/scrapy/scrapy/issues/7929), [#8009](https://github.com/scrapy/scrapy/issues/8009))
- Increased the minimum versions of the following dependencies:
  - [cryptography](https://cryptography.io/en/latest/): 37.0.0 → 41.0.5
  - [pyOpenSSL](https://www.pyopenssl.org/en/stable/): 22.0.0 → 24.3.0
  - [queuelib](https://github.com/scrapy/queuelib): 1.4.2 → 1.6.1
  - [service_identity](https://service-identity.readthedocs.io/en/stable/): 23.1.0 → 24.2.0
  - [w3lib](https://github.com/scrapy/w3lib): 1.17.0 → 2.1.1

  ([#7841](https://github.com/scrapy/scrapy/issues/7841), [#7874](https://github.com/scrapy/scrapy/issues/7874), [#7879](https://github.com/scrapy/scrapy/issues/7879), [#8001](https://github.com/scrapy/scrapy/issues/8001))
- The IPython [shell](topics/shell.md) requires IPython 8.15.0 or higher.
  Install the [ipython extra](intro/install.md "Optional extras") to get a compatible version.
  ([#5447](https://github.com/scrapy/scrapy/issues/5447), [#7596](https://github.com/scrapy/scrapy/issues/7596), [#7816](https://github.com/scrapy/scrapy/issues/7816))

### Backward-incompatible changes

- The following runtime usage of [zope.interface](https://zopeinterface.readthedocs.io/en/latest/) interfaces is removed:
  - [`SpiderLoader`](topics/api.md) and
    [`DummySpiderLoader`](topics/api.md) 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`](topics/feed-exports.md),
    [`FileFeedStorage`](topics/feed-exports.md) and
    [`StdoutFeedStorage`](topics/feed-exports.md) are no longer
    marked as implementing the `IFeedStorage` interface.
  - [`H2DownloadHandler`](topics/download-handlers.md) no
    longer checks that the `DOWNLOADER_CLIENTCONTEXTFACTORY` class
    implements the `IPolicyForHTTPS` interface.

  ([#6585](https://github.com/scrapy/scrapy/issues/6585), [#7731](https://github.com/scrapy/scrapy/issues/7731))
- The [`engine`](topics/api.md),
  [`extensions`](topics/api.md),
  [`logformatter`](topics/api.md),
  [`request_fingerprinter`](topics/api.md) and
  [`stats`](topics/api.md) attributes of
  [`Crawler`](topics/api.md) raise `RuntimeError` when read before
  the crawl starts, instead of being `None` until then.

  Code that reads them from the [`spider_opened`](topics/signals.md) 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](https://github.com/scrapy/scrapy/issues/6136), [#7882](https://github.com/scrapy/scrapy/issues/7882))
- [Item exporters](topics/exporters.md) now export the fields of an item
  in declaration order, i.e. the order in which they are defined in the
  [item class](topics/items.md "Item Types"), instead of the order in which they were
  populated, as [`CsvItemExporter`](topics/exporters.md) already did.
  `dict` items, which have no declared fields, keep using the key
  order of each item.
  ([#6662](https://github.com/scrapy/scrapy/issues/6662), [#6854](https://github.com/scrapy/scrapy/issues/6854), [#7824](https://github.com/scrapy/scrapy/issues/7824))
- `scrapy.utils.serialize.ScrapyJSONEncoder`, used by [JSON feed
  exports](topics/feed-exports.md "JSON"), the [telnet console](topics/telnetconsole.md) and the
  [`PeriodicLog`](topics/extensions.md) extension, now
  serializes [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime), [`date`](https://docs.python.org/3/library/datetime.html#datetime.date) and
  [`time`](https://docs.python.org/3/library/datetime.html#datetime.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](https://github.com/scrapy/scrapy/issues/2087), [#7918](https://github.com/scrapy/scrapy/issues/7918))
- `scrapy.utils.trackref.live_refs` is now a
  [`WeakKeyDictionary`](https://docs.python.org/3/library/weakref.html#weakref.WeakKeyDictionary) instead of a
  [`collections.defaultdict`](https://docs.python.org/3/library/collections.html#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](https://github.com/scrapy/scrapy/issues/5995), [#7922](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7737))
- `scrapy.utils.log.logformatter_adapter()` no longer passes the whole
  `dict` returned by a [log formatter](topics/logging.md "Custom Log Formats")
  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](https://github.com/scrapy/scrapy/issues/5570), [#5572](https://github.com/scrapy/scrapy/issues/5572), [#7936](https://github.com/scrapy/scrapy/issues/7936))
- [`FEEDS`](topics/feed-exports.md) keys and `FEED_URI` values that are
  [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html#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](topics/feed-exports.md "Storage URI parameters") or characters that
  URI conversion would percent-encode.
  ([#5794](https://github.com/scrapy/scrapy/issues/5794), [#6425](https://github.com/scrapy/scrapy/issues/6425), [#6611](https://github.com/scrapy/scrapy/issues/6611), [#7674](https://github.com/scrapy/scrapy/issues/7674))
- [`Selector`](topics/selectors.md) and [`TextResponse.selector`](topics/request-response.md) no longer force the `html` selector
  type for responses that are neither [`HtmlResponse`](topics/request-response.md) nor
  [`XmlResponse`](topics/request-response.md) objects. A
  [`JsonResponse`](topics/request-response.md) 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](https://github.com/scrapy/scrapy/issues/4627), [#5291](https://github.com/scrapy/scrapy/issues/5291), [#6025](https://github.com/scrapy/scrapy/issues/6025), [#7924](https://github.com/scrapy/scrapy/issues/7924), [#7972](https://github.com/scrapy/scrapy/issues/7972))
- [AutoThrottle](topics/autothrottle.md) 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](https://github.com/scrapy/scrapy/issues/7167), [#7175](https://github.com/scrapy/scrapy/issues/7175), [#7833](https://github.com/scrapy/scrapy/issues/7833))
- The [`check`](topics/commands.md) command now ignores [`ITEM_PIPELINES`](topics/settings.md) and
  [`FEEDS`](topics/feed-exports.md), 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](https://github.com/scrapy/scrapy/issues/3385), [#7957](https://github.com/scrapy/scrapy/issues/7957))
- [`XMLFeedSpider`](topics/spiders.md) and
  [`CSVFeedSpider`](topics/spiders.md) no longer raise
  [`NotConfigured`](topics/exceptions.md) when `parse_node()` or
  `parse_row()` is not defined; the resulting `AttributeError` is
  reported instead.
  ([#7768](https://github.com/scrapy/scrapy/issues/7768))

### Deprecation removals

- `scrapy.utils.misc.md5sum()`, deprecated since Scrapy 2.12.0, is
  removed.
  ([#6264](https://github.com/scrapy/scrapy/issues/6264), [#8023](https://github.com/scrapy/scrapy/issues/8023))
- `scrapy.utils.iterators.xmliter()`, deprecated since Scrapy 2.11.1
  because it is vulnerable to ReDoS attacks, is removed. Use
  [`xmliter_lxml()`](faq.md) instead.
  ([#7765](https://github.com/scrapy/scrapy/issues/7765))
- `scrapy.utils.datatypes.CaselessDict`, deprecated since Scrapy 2.10.0,
  is removed. Use
  `CaseInsensitiveDict` instead.
  ([#5146](https://github.com/scrapy/scrapy/issues/5146), [#8023](https://github.com/scrapy/scrapy/issues/8023))

### Deprecations

- The `download_delay` spider attribute is deprecated. Use the
  [`DOWNLOAD_DELAY`](topics/settings.md) setting, or [`DOWNLOAD_SLOTS`](topics/settings.md) 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`](topics/settings.md) 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](https://github.com/scrapy/scrapy/issues/7167), [#7175](https://github.com/scrapy/scrapy/issues/7175), [#7833](https://github.com/scrapy/scrapy/issues/7833))
- The `Spider.log()` method is deprecated. Use the methods of
  [`Spider.logger`](topics/spiders.md) instead.
  ([#7739](https://github.com/scrapy/scrapy/issues/7739))
- The `scrapy.interfaces` module and its `ISpiderLoader` interface are
  deprecated. Custom spider loaders only need to follow
  [`SpiderLoaderProtocol`](topics/api.md).
  ([#6585](https://github.com/scrapy/scrapy/issues/6585), [#7731](https://github.com/scrapy/scrapy/issues/7731))
- `scrapy.extensions.feedexport.IFeedStorage` is deprecated. Custom feed
  storages only need to follow
  `scrapy.extensions.feedexport.FeedStorageProtocol`.
  ([#6585](https://github.com/scrapy/scrapy/issues/6585), [#7731](https://github.com/scrapy/scrapy/issues/7731))
- `scrapy.utils.python.re_rsearch()` is deprecated.
  ([#7765](https://github.com/scrapy/scrapy/issues/7765))
- Importing `FileException` from `scrapy.pipelines.files` is deprecated.
  Import it from `scrapy.pipelines.media` instead.
  ([#7544](https://github.com/scrapy/scrapy/issues/7544), [#7673](https://github.com/scrapy/scrapy/issues/7673), [#7973](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7738))
- The unused `multiplier` attribute of
  [`PeriodicLog`](topics/extensions.md) is deprecated.
  ([#7809](https://github.com/scrapy/scrapy/issues/7809), [#7982](https://github.com/scrapy/scrapy/issues/7982))
- Returning, from a [log formatter](topics/logging.md "Custom Log Formats") 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](https://github.com/scrapy/scrapy/issues/5570), [#7971](https://github.com/scrapy/scrapy/issues/7971))

### New features

- Added [optional extras](intro/install.md) for every optional dependency of
  Scrapy: `bpython`, `gcs`, `httpx`, `images`, `ipython`,
  `ptpython`, `robotparser`, `s3`, `twisted-http2` and `uvloop`.
  For example, `pip install scrapy[s3,images]`.
  ([#7596](https://github.com/scrapy/scrapy/issues/7596))
- [`HttpxDownloadHandler`](topics/download-handlers.md) now
  uses [httpx2](https://httpx2.pydantic.dev/), the successor of `httpx`,
  which the new [httpx extra](intro/install.md "Optional extras") installs together with its HTTP/2
  and SOCKS proxy support. `httpx` is still used when `httpx2` is not
  installed, but it is no longer tested.
  ([#7762](https://github.com/scrapy/scrapy/issues/7762))
- Added a [`robots_parsed`](topics/signals.md) signal, sent by
  [`RobotsTxtMiddleware`](topics/downloader-middleware.md) after
  it parses a `robots.txt` file. It supports [asynchronous
  handlers](topics/signals.md "Asynchronous signal handlers").

  Added a [`crawl_delay()`](topics/downloader-middleware.md) method to
  [`RobotParser`](topics/downloader-middleware.md), implemented by all built-in
  [robots.txt parsers](topics/downloader-middleware.md "RobotsTxtMiddleware").

  ([#7830](https://github.com/scrapy/scrapy/issues/7830))
- Added a [`Request.to_curl()`](topics/request-response.md) method, the
  inverse of [`from_curl()`](topics/request-response.md).
  ([#7743](https://github.com/scrapy/scrapy/issues/7743), [#7746](https://github.com/scrapy/scrapy/issues/7746), [#7802](https://github.com/scrapy/scrapy/issues/7802))
- Added a [`depth_reset`](topics/spider-middleware.md) request meta key that gives a request depth
  0 instead of the depth of its source response plus 1.
  ([#891](https://github.com/scrapy/scrapy/issues/891), [#7913](https://github.com/scrapy/scrapy/issues/7913))
- Added
  [`MetaCopyDetectionMiddleware`](topics/spider-middleware.md),
  enabled by default, which warns once per crawl when a spider yields a
  request carrying internal [`meta`](topics/request-response.md) keys that were
  likely copied from `response.meta`, and a
  [`META_COPY_WARN_SKIP_KEYS`](topics/spider-middleware.md) setting to exclude keys from that
  check.
  ([#7588](https://github.com/scrapy/scrapy/issues/7588))
- Added an [`AWS_MAX_POOL_CONNECTIONS`](topics/settings.md) setting, which defines the
  connection pool size of the AWS clients of the [S3 feed storage
  backend](topics/feed-exports.md "S3") and the [S3 media pipeline storage
  backend](topics/media-pipeline.md "Amazon S3 storage"), and defaults to
  [`REACTOR_THREADPOOL_MAXSIZE`](topics/settings.md). It is also exposed as a
  `max_pool_connections` parameter of `S3FeedStorage` and as an
  `AWS_MAX_POOL_CONNECTIONS` attribute of `S3FilesStore`.
  ([#4985](https://github.com/scrapy/scrapy/issues/4985), [#7794](https://github.com/scrapy/scrapy/issues/7794))
- Added a [`scrapy.utils.asyncio.sleep()`](topics/asyncio.md) function, which works both with
  and without a Twisted reactor.
  ([#7843](https://github.com/scrapy/scrapy/issues/7843))
- [`CONCURRENT_REQUESTS`](topics/settings.md) can now be set to `0` for no limit.
  ([#7840](https://github.com/scrapy/scrapy/issues/7840))
- [`H2DownloadHandler`](topics/download-handlers.md) is no
  longer experimental, and it now sends the [`bytes_received`](topics/signals.md) and
  [`headers_received`](topics/signals.md) signals and supports
  [`StopDownload`](topics/exceptions.md).
  ([#5046](https://github.com/scrapy/scrapy/issues/5046), [#5047](https://github.com/scrapy/scrapy/issues/5047), [#5055](https://github.com/scrapy/scrapy/issues/5055), [#7896](https://github.com/scrapy/scrapy/issues/7896), [#7986](https://github.com/scrapy/scrapy/issues/7986))
- An exception raised by [`Spider.start()`](topics/spiders.md) is now
  reported through the [`spider_error`](topics/signals.md) signal and the
  [`spider_exceptions/count`](topics/stats.md) and [`spider_exceptions/{exception}`](topics/stats.md)
  stats, and closes the spider with the new `start_error`
  [`finish_reason`](topics/stats.md) instead of `finished`. See [Handling start errors](topics/spiders.md).

  [`CloseSpider`](topics/exceptions.md) raised from [`Spider.start()`](topics/spiders.md) now closes the spider with the given reason, instead
  of being reported as a start error.

  ([#3463](https://github.com/scrapy/scrapy/issues/3463), [#4058](https://github.com/scrapy/scrapy/issues/4058), [#4182](https://github.com/scrapy/scrapy/issues/4182), [#6148](https://github.com/scrapy/scrapy/issues/6148), [#7884](https://github.com/scrapy/scrapy/issues/7884))
- [`CloseSpider`](topics/exceptions.md) can now also be raised while the
  spider is starting, e.g. from a [`spider_opened`](topics/signals.md) signal handler or
  from the `open_spider()` method of an [item pipeline](topics/item-pipeline.md), to close the spider before it starts crawling.
  Every component still gets started, and stopped, before the spider is
  closed with the given reason.
  ([#3435](https://github.com/scrapy/scrapy/issues/3435), [#7905](https://github.com/scrapy/scrapy/issues/7905))
- Added an [FTPS feed storage backend](topics/feed-exports.md "FTPS"), i.e. support
  for the `ftps` URI scheme in [`FEEDS`](topics/feed-exports.md), which uploads the feed
  over a TLS connection, verifying the certificate of the server.
  ([#4180](https://github.com/scrapy/scrapy/issues/4180), [#7953](https://github.com/scrapy/scrapy/issues/7953))
- Changes to [`Spider.allowed_domains`](topics/spiders.md)
  during a crawl are now taken into account by
  [`OffsiteMiddleware`](topics/downloader-middleware.md), whose
  [`should_follow()`](topics/downloader-middleware.md)
  method is now documented as the way to implement a different offsite
  policy.
  ([#3257](https://github.com/scrapy/scrapy/issues/3257), [#3412](https://github.com/scrapy/scrapy/issues/3412), [#7903](https://github.com/scrapy/scrapy/issues/7903), [#7912](https://github.com/scrapy/scrapy/issues/7912))
- [`BaseSettings`](topics/api.md) methods that take settings, such as
  [`update()`](topics/api.md) and the `settings` parameter
  of crawler classes, now also accept an iterable of `(name, value)`
  tuples.
  ([#7759](https://github.com/scrapy/scrapy/issues/7759), [#7763](https://github.com/scrapy/scrapy/issues/7763))
- The `cookies` parameter of [`Request`](topics/request-response.md) now also accepts
  `bool`, `float` and `int` values, and the `formdata`
  parameter of [`FormRequest`](topics/request-response.md) now accepts any mapping or
  iterable of key-value pairs.
  ([#7858](https://github.com/scrapy/scrapy/issues/7858), [#7864](https://github.com/scrapy/scrapy/issues/7864))
- Added a `scrapy.utils.reactorless.uninstall_reactor_import_hook()`
  function, which [`AsyncCrawlerProcess.start()`](topics/api.md) now uses to uninstall the
  [`twisted.internet.reactor`](https://docs.twisted.org/en/stable/api/twisted.internet.reactor.html) import hook when it exits.
  ([#7747](https://github.com/scrapy/scrapy/issues/7747))
- Added the [`depth/request_ignored_count`](topics/stats.md) and
  [`httpcache/retrieve_error`](topics/stats.md) stats.
  ([#1308](https://github.com/scrapy/scrapy/issues/1308), [#2222](https://github.com/scrapy/scrapy/issues/2222), [#7805](https://github.com/scrapy/scrapy/issues/7805), [#7916](https://github.com/scrapy/scrapy/issues/7916))
- The [`get_serialized_fields()`](topics/exporters.md) method
  of [item exporters](topics/exporters.md), previously named
  `_get_serialized_fields()`, is now public and documented, for
  [custom item exporters](topics/exporters.md "Writing your own item exporter") to use.
  ([#5706](https://github.com/scrapy/scrapy/issues/5706), [#7931](https://github.com/scrapy/scrapy/issues/7931))
- Scrapy now writes the session keys of its HTTPS connections to the file
  that the `SSLKEYLOGFILE` environment variable points to, so that traffic
  analysis tools such as Wireshark can decrypt them. See [Decrypting TLS traffic](topics/debug.md).
  ([#4368](https://github.com/scrapy/scrapy/issues/4368), [#7948](https://github.com/scrapy/scrapy/issues/7948))
- Added an [`HTTP2_MAX_FRAME_SIZE`](topics/settings.md) setting, which allows raising the
  maximum HTTP/2 frame size that servers may send, previously fixed at
  16384, above which connections failed.
  ([#5050](https://github.com/scrapy/scrapy/issues/5050), [#7988](https://github.com/scrapy/scrapy/issues/7988))
- The [`crawl`](topics/commands.md), [`parse`](topics/commands.md) and [`runspider`](topics/commands.md) commands
  now warn when [`FEEDS`](topics/feed-exports.md) is set, e.g. through `-o` or `-O`, but
  the `FeedExporter` extension is
  disabled, so that no item is exported.
  ([#5970](https://github.com/scrapy/scrapy/issues/5970), [#6082](https://github.com/scrapy/scrapy/issues/6082), [#6373](https://github.com/scrapy/scrapy/issues/6373), [#7902](https://github.com/scrapy/scrapy/issues/7902))
- Log formatters ([`LOG_FORMATTER`](topics/settings.md)), item processors
  ([`ITEM_PROCESSOR`](topics/settings.md)) and [robots.txt parsers](topics/downloader-middleware.md "RobotsTxtMiddleware") ([`ROBOTSTXT_PARSER`](topics/settings.md)) are now built as
  [components](topics/components.md), so they no longer need a
  `from_crawler()` method.
  ([#7808](https://github.com/scrapy/scrapy/issues/7808))

### Bug fixes

- [`HttpCacheMiddleware`](topics/downloader-middleware.md) 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`](topics/stats.md) stat.
  ([#2222](https://github.com/scrapy/scrapy/issues/2222), [#7805](https://github.com/scrapy/scrapy/issues/7805))
- [Feed URIs](topics/feed-exports.md "Storage URI parameters") 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](https://github.com/scrapy/scrapy/issues/5794), [#6425](https://github.com/scrapy/scrapy/issues/6425), [#7674](https://github.com/scrapy/scrapy/issues/7674))
- [Feed exports](topics/feed-exports.md) now start storing a
  [`FEED_EXPORT_BATCH_ITEM_COUNT`](topics/feed-exports.md) batch as soon as it is complete,
  instead of waiting until the spider closes.
  ([#7730](https://github.com/scrapy/scrapy/issues/7730), [#7733](https://github.com/scrapy/scrapy/issues/7733))
- [`CsvItemExporter`](topics/exporters.md) 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](https://github.com/scrapy/scrapy/issues/4002), [#4053](https://github.com/scrapy/scrapy/issues/4053), [#7613](https://github.com/scrapy/scrapy/issues/7613), [#7651](https://github.com/scrapy/scrapy/issues/7651))
- `GCSFeedStorage` no longer requires the `storage.buckets.get`
  permission.
  ([#5475](https://github.com/scrapy/scrapy/issues/5475), [#7945](https://github.com/scrapy/scrapy/issues/7945))
- [Media pipelines](topics/media-pipeline.md) 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](https://github.com/scrapy/scrapy/issues/7544), [#7673](https://github.com/scrapy/scrapy/issues/7673))
- [`OffsiteMiddleware`](topics/downloader-middleware.md) now raises
  [`IgnoreRequest`](topics/exceptions.md) with a message, e.g. `Filtered
  offsite request to 'offsite.example'`, which errbacks and log messages
  that report that exception now include.
  ([#7544](https://github.com/scrapy/scrapy/issues/7544), [#7673](https://github.com/scrapy/scrapy/issues/7673))
- [`HTTP11DownloadHandler`](topics/download-handlers.md) 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](https://github.com/scrapy/scrapy/issues/210), [#7806](https://github.com/scrapy/scrapy/issues/7806))
- [`CookiesMiddleware`](topics/cookies.md) now sends
  domain cookies to hosts without a dot in their name and to hosts given as
  an IP address.
  ([#6410](https://github.com/scrapy/scrapy/issues/6410), [#7900](https://github.com/scrapy/scrapy/issues/7900))
- [`TextResponse.json()`](topics/request-response.md) now decodes
  bodies that are not valid UTF-8, UTF-16 or UTF-32 using
  [`TextResponse.encoding`](topics/request-response.md), instead
  of raising `UnicodeDecodeError`.
  ([#6456](https://github.com/scrapy/scrapy/issues/6456), [#7897](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/6442), [#7772](https://github.com/scrapy/scrapy/issues/7772))
- [`DownloaderAwarePriorityQueue`](topics/scheduler.md) now removes the
  directory of a download slot from the [`JOBDIR`](topics/settings.md) directory once that
  slot is drained.
  ([#5275](https://github.com/scrapy/scrapy/issues/5275), [#7955](https://github.com/scrapy/scrapy/issues/7955))
- [`TelnetConsole`](topics/extensions.md) no longer raises an
  exception on shutdown when it could not listen on any of the
  [`TELNETCONSOLE_PORT`](topics/telnetconsole.md) ports.
  ([#2702](https://github.com/scrapy/scrapy/issues/2702), [#7910](https://github.com/scrapy/scrapy/issues/7910))
- The [`DOWNLOAD_WARNSIZE`](topics/settings.md) warning is no longer logged twice for a
  response whose `Content-Length` header already exceeded the limit.
  ([#2476](https://github.com/scrapy/scrapy/issues/2476), [#7963](https://github.com/scrapy/scrapy/issues/7963))
- [`HttpCompressionMiddleware`](topics/downloader-middleware.md)
  now logs a warning when it drops a response for exceeding
  [`DOWNLOAD_MAXSIZE`](topics/settings.md) during decompression.
  ([#6616](https://github.com/scrapy/scrapy/issues/6616), [#7742](https://github.com/scrapy/scrapy/issues/7742))
- [`DepthMiddleware`](topics/spider-middleware.md) now logs only the
  first request ignored for exceeding [`DEPTH_LIMIT`](topics/settings.md), and counts them
  all in the new [`depth/request_ignored_count`](topics/stats.md) stat.
  ([#1308](https://github.com/scrapy/scrapy/issues/1308), [#7916](https://github.com/scrapy/scrapy/issues/7916))
- [`parse`](topics/commands.md) now sets the callback it uses on the request of the
  response it passes to that callback.
  ([#3095](https://github.com/scrapy/scrapy/issues/3095), [#3124](https://github.com/scrapy/scrapy/issues/3124), [#7803](https://github.com/scrapy/scrapy/issues/7803))
- The IPython [shell](topics/shell.md) 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](https://github.com/scrapy/scrapy/issues/5447), [#7816](https://github.com/scrapy/scrapy/issues/7816))
- [`Request.from_curl()`](topics/request-response.md) 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](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7783))
- [`ExecutionEngine.download_async()`](topics/api.md) no longer recurses
  once per returned request, e.g. once per redirect.
  ([#7544](https://github.com/scrapy/scrapy/issues/7544), [#7673](https://github.com/scrapy/scrapy/issues/7673))
- [`LinkExtractor`](topics/link-extractors.md)
  now canonicalizes each extracted URL once instead of twice when
  `canonicalize` is `True`.
  ([#7961](https://github.com/scrapy/scrapy/issues/7961))
- Items yielded from [`Spider.start()`](topics/spiders.md) now keep
  the spider busy until the [item pipelines](topics/item-pipeline.md) are
  done with them, so that a spider that only yields items from
  [`start()`](topics/spiders.md) no longer closes before processing them.
  ([#7029](https://github.com/scrapy/scrapy/issues/7029), [#7891](https://github.com/scrapy/scrapy/issues/7891))
- [`open_in_browser()`](topics/debug.md) 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](https://github.com/scrapy/scrapy/issues/6550), [#7879](https://github.com/scrapy/scrapy/issues/7879))
- [`Spider.start()`](topics/spiders.md) 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](https://github.com/scrapy/scrapy/issues/5426), [#7946](https://github.com/scrapy/scrapy/issues/7946))
- The [`check`](topics/commands.md), [`fetch`](topics/commands.md) and [`parse`](topics/commands.md) commands now
  return the exit code 1 when a component fails to initialize, as
  [`crawl`](topics/commands.md) and [`runspider`](topics/commands.md) already did.
  ([#4292](https://github.com/scrapy/scrapy/issues/4292), [#7920](https://github.com/scrapy/scrapy/issues/7920))
- [`HttpCompressionMiddleware`](topics/downloader-middleware.md)
  no longer hangs on a `deflate` response body followed by extra bytes.
  ([#7841](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7841))
- Fixed `NameError` exceptions on Python 3.14, where [**PEP 649**](https://peps.python.org/pep-0649/) made
  annotation evaluation lazy, when inspecting the signature of a callable
  with annotations imported only for type checking.
  ([#7796](https://github.com/scrapy/scrapy/issues/7796), [#7818](https://github.com/scrapy/scrapy/issues/7818))
- `scrapy.utils.decorators.deprecated` can now be used both as
  `@deprecated` and as `@deprecated(...)` without confusing type
  checkers.
  ([#7797](https://github.com/scrapy/scrapy/issues/7797))
- The default download handlers can now download from domains with emoji
  characters or underscores, which were previously rejected.
  ([#3321](https://github.com/scrapy/scrapy/issues/3321), [#4330](https://github.com/scrapy/scrapy/issues/4330), [#7846](https://github.com/scrapy/scrapy/issues/7846))
- Callbacks and media pipeline results no longer wait 100 ms before
  proceeding.
  ([#8019](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/8022))
- Nested selectors, e.g. the result of calling
  [`jmespath()`](topics/selectors.md) 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](https://github.com/scrapy/scrapy/issues/8038), [#8040](https://github.com/scrapy/scrapy/issues/8040))

### Documentation

- Added a [built-in stats reference](topics/stats.md), covering
  every stat that Scrapy sets.
  ([#6351](https://github.com/scrapy/scrapy/issues/6351), [#7814](https://github.com/scrapy/scrapy/issues/7814))
- Replaced the broad crawls page with a new [optimization](topics/optimize.md)
  page, about finding the bottleneck of a crawl before changing any setting,
  which covers [broad crawls](topics/optimize.md "Speeding up broad crawls") as one of its sections.
  ([#4737](https://github.com/scrapy/scrapy/issues/4737), [#7938](https://github.com/scrapy/scrapy/issues/7938))
- Added a [concepts](topics/concepts.md) page, a quick map of Scrapy’s main
  building blocks, what problem each one solves, and when to reach for it.
  ([#1569](https://github.com/scrapy/scrapy/issues/1569), [#8025](https://github.com/scrapy/scrapy/issues/8025))
- Added a [cookies](topics/cookies.md) page, which gathers what used to be
  spread across the request and downloader middleware pages.
  ([#7947](https://github.com/scrapy/scrapy/issues/7947))
- Added [callbacks](topics/request-response.md) and [errbacks](topics/request-response.md) sections
  to the request and response page, covering [callback assignment](topics/request-response.md "Assigning a callback to a request"), [how to write a callback](topics/request-response.md "Writing a callback")
  and [supported callback output](topics/request-response.md "Callback output").
  ([#5054](https://github.com/scrapy/scrapy/issues/5054), [#6437](https://github.com/scrapy/scrapy/issues/6437), [#7821](https://github.com/scrapy/scrapy/issues/7821), [#7898](https://github.com/scrapy/scrapy/issues/7898))
- Documented the [`ITEM_PROCESSOR`](topics/settings.md) setting and the
  [`ItemProcessorProtocol`](topics/settings.md) protocol that its value
  must implement.
  ([#7983](https://github.com/scrapy/scrapy/issues/7983))
- Documented [how to write an item exporter](topics/exporters.md "Writing your own item exporter"),
  [how to test an item pipeline](topics/item-pipeline.md "Testing an item pipeline"), [how to
  download a request from a downloader middleware](topics/downloader-middleware.md "Downloading a request from a downloader middleware"), [how
  to name media files after the response](topics/media-pipeline.md "Naming files after the response"), [how
  to add objects to the shell](topics/shell.md "Adding your own objects") and [how to run
  spiders inside an existing application](topics/practices.md "Running spiders inside existing applications") or [in a
  Jupyter notebook](topics/practices.md "Running spiders in Jupyter notebooks").
  ([#915](https://github.com/scrapy/scrapy/issues/915),
  [#1199](https://github.com/scrapy/scrapy/issues/1199),
  [#2594](https://github.com/scrapy/scrapy/issues/2594),
  [#5706](https://github.com/scrapy/scrapy/issues/5706),
  [#6554](https://github.com/scrapy/scrapy/issues/6554),
  [#6594](https://github.com/scrapy/scrapy/issues/6594),
  [#7751](https://github.com/scrapy/scrapy/issues/7751),
  [#7872](https://github.com/scrapy/scrapy/issues/7872),
  [#7876](https://github.com/scrapy/scrapy/issues/7876),
  [#7889](https://github.com/scrapy/scrapy/issues/7889),
  [#7909](https://github.com/scrapy/scrapy/issues/7909),
  [#7931](https://github.com/scrapy/scrapy/issues/7931))
- Added an [inspecting live traffic](topics/debug.md) section to the
  debugging page, covering Wireshark and mitmproxy.
  ([#5222](https://github.com/scrapy/scrapy/issues/5222), [#8007](https://github.com/scrapy/scrapy/issues/8007))
- Documented how [`TextResponse`](topics/request-response.md) resolves the response
  encoding, and how to resolve it differently, e.g. to give the encoding
  declared in the response body precedence over the `Content-Type` header.
  ([#4933](https://github.com/scrapy/scrapy/issues/4933), [#7977](https://github.com/scrapy/scrapy/issues/7977))
- Documented the [memory use of response parsing](topics/security.md "Memory use when parsing responses") and the [parser limits](topics/security.md) that Scrapy lifts, in the security page.
  ([#5700](https://github.com/scrapy/scrapy/issues/5700), [#7930](https://github.com/scrapy/scrapy/issues/7930))
- Documented that [signal handlers run in an undefined order](topics/signals.md "Handler order"), that [`scheduler_empty`](topics/signals.md) must only be awaited from
  [`start()`](topics/spiders.md), that concurrency and politeness settings
  apply per crawler when [running multiple spiders in the same process](topics/practices.md), and that a [`JOBDIR`](topics/settings.md) directory cannot be
  shared across Scrapy versions.
  ([#3191](https://github.com/scrapy/scrapy/issues/3191),
  [#5330](https://github.com/scrapy/scrapy/issues/5330),
  [#5522](https://github.com/scrapy/scrapy/issues/5522),
  [#7861](https://github.com/scrapy/scrapy/issues/7861),
  [#7883](https://github.com/scrapy/scrapy/issues/7883),
  [#7907](https://github.com/scrapy/scrapy/issues/7907),
  [#7941](https://github.com/scrapy/scrapy/issues/7941))
- Documented that the `html` iterator of
  [`XMLFeedSpider`](topics/spiders.md) can silently mangle tags that HTML
  treats as void elements, e.g. `<link>`, dropping their content and
  closing tag.
  ([#4675](https://github.com/scrapy/scrapy/issues/4675), [#8045](https://github.com/scrapy/scrapy/issues/8045))
- Documented that the `keep_fragments` parameter of
  [`fingerprint()`](topics/request-response.md) is not a substitute for
  rendering JavaScript to reach content that a headless browser loads based
  on the URL fragment.
  ([#4789](https://github.com/scrapy/scrapy/issues/4789), [#8033](https://github.com/scrapy/scrapy/issues/8033))
- Documented [how to derive the job directory from the spider name](topics/jobs.md "Deriving the job directory from the spider name").
  ([#4748](https://github.com/scrapy/scrapy/issues/4748), [#8035](https://github.com/scrapy/scrapy/issues/8035))
- Documented that the project name from `scrapy.cfg` also appears
  elsewhere by default, and which of those uses actually require it to
  match.
  ([#2484](https://github.com/scrapy/scrapy/issues/2484), [#8044](https://github.com/scrapy/scrapy/issues/8044))
- Many other corrections and improvements.
  ([#4589](https://github.com/scrapy/scrapy/issues/4589),
  [#4796](https://github.com/scrapy/scrapy/issues/4796),
  [#5532](https://github.com/scrapy/scrapy/issues/5532),
  [#5548](https://github.com/scrapy/scrapy/issues/5548),
  [#6053](https://github.com/scrapy/scrapy/issues/6053),
  [#6184](https://github.com/scrapy/scrapy/issues/6184),
  [#6627](https://github.com/scrapy/scrapy/issues/6627),
  [#6787](https://github.com/scrapy/scrapy/issues/6787),
  [#6943](https://github.com/scrapy/scrapy/issues/6943),
  [#6989](https://github.com/scrapy/scrapy/issues/6989),
  [#7710](https://github.com/scrapy/scrapy/issues/7710),
  [#7725](https://github.com/scrapy/scrapy/issues/7725),
  [#7737](https://github.com/scrapy/scrapy/issues/7737),
  [#7767](https://github.com/scrapy/scrapy/issues/7767),
  [#7769](https://github.com/scrapy/scrapy/issues/7769),
  [#7771](https://github.com/scrapy/scrapy/issues/7771),
  [#7774](https://github.com/scrapy/scrapy/issues/7774),
  [#7775](https://github.com/scrapy/scrapy/issues/7775),
  [#7777](https://github.com/scrapy/scrapy/issues/7777),
  [#7779](https://github.com/scrapy/scrapy/issues/7779),
  [#7780](https://github.com/scrapy/scrapy/issues/7780),
  [#7817](https://github.com/scrapy/scrapy/issues/7817),
  [#7832](https://github.com/scrapy/scrapy/issues/7832),
  [#7835](https://github.com/scrapy/scrapy/issues/7835),
  [#7862](https://github.com/scrapy/scrapy/issues/7862),
  [#7871](https://github.com/scrapy/scrapy/issues/7871),
  [#7875](https://github.com/scrapy/scrapy/issues/7875),
  [#7880](https://github.com/scrapy/scrapy/issues/7880),
  [#7890](https://github.com/scrapy/scrapy/issues/7890),
  [#7903](https://github.com/scrapy/scrapy/issues/7903),
  [#7913](https://github.com/scrapy/scrapy/issues/7913),
  [#7917](https://github.com/scrapy/scrapy/issues/7917),
  [#7939](https://github.com/scrapy/scrapy/issues/7939),
  [#7940](https://github.com/scrapy/scrapy/issues/7940),
  [#7962](https://github.com/scrapy/scrapy/issues/7962),
  [#7965](https://github.com/scrapy/scrapy/issues/7965))

### Quality assurance

- Improved and fixed type hints.
  ([#7712](https://github.com/scrapy/scrapy/issues/7712),
  [#7785](https://github.com/scrapy/scrapy/issues/7785),
  [#7858](https://github.com/scrapy/scrapy/issues/7858),
  [#7864](https://github.com/scrapy/scrapy/issues/7864),
  [#7865](https://github.com/scrapy/scrapy/issues/7865),
  [#7867](https://github.com/scrapy/scrapy/issues/7867))
- Added CPU benchmarks, tracked on CodSpeed, so that performance regressions
  are caught before they are merged and performance work can be measured.
  ([#7831](https://github.com/scrapy/scrapy/issues/7831),
  [#7839](https://github.com/scrapy/scrapy/issues/7839),
  [#7870](https://github.com/scrapy/scrapy/issues/7870),
  [#7887](https://github.com/scrapy/scrapy/issues/7887),
  [#7914](https://github.com/scrapy/scrapy/issues/7914),
  [#7954](https://github.com/scrapy/scrapy/issues/7954))
- Added a nightly job that runs the test suite against the development
  branches of dependencies, so that incompatibilities are found before those
  dependencies are released.
  ([#5291](https://github.com/scrapy/scrapy/issues/5291), [#6025](https://github.com/scrapy/scrapy/issues/6025), [#7924](https://github.com/scrapy/scrapy/issues/7924), [#7960](https://github.com/scrapy/scrapy/issues/7960))
- CI and test improvements and fixes.
  ([#5049](https://github.com/scrapy/scrapy/issues/5049),
  [#5620](https://github.com/scrapy/scrapy/issues/5620),
  [#5837](https://github.com/scrapy/scrapy/issues/5837),
  [#6478](https://github.com/scrapy/scrapy/issues/6478),
  [#6794](https://github.com/scrapy/scrapy/issues/6794),
  [#7262](https://github.com/scrapy/scrapy/issues/7262),
  [#7437](https://github.com/scrapy/scrapy/issues/7437),
  [#7702](https://github.com/scrapy/scrapy/issues/7702),
  [#7720](https://github.com/scrapy/scrapy/issues/7720),
  [#7724](https://github.com/scrapy/scrapy/issues/7724),
  [#7727](https://github.com/scrapy/scrapy/issues/7727),
  [#7736](https://github.com/scrapy/scrapy/issues/7736),
  [#7741](https://github.com/scrapy/scrapy/issues/7741),
  [#7749](https://github.com/scrapy/scrapy/issues/7749),
  [#7753](https://github.com/scrapy/scrapy/issues/7753),
  [#7755](https://github.com/scrapy/scrapy/issues/7755),
  [#7768](https://github.com/scrapy/scrapy/issues/7768),
  [#7778](https://github.com/scrapy/scrapy/issues/7778),
  [#7782](https://github.com/scrapy/scrapy/issues/7782),
  [#7792](https://github.com/scrapy/scrapy/issues/7792),
  [#7793](https://github.com/scrapy/scrapy/issues/7793),
  [#7795](https://github.com/scrapy/scrapy/issues/7795),
  [#7797](https://github.com/scrapy/scrapy/issues/7797),
  [#7798](https://github.com/scrapy/scrapy/issues/7798),
  [#7809](https://github.com/scrapy/scrapy/issues/7809),
  [#7829](https://github.com/scrapy/scrapy/issues/7829),
  [#7834](https://github.com/scrapy/scrapy/issues/7834),
  [#7836](https://github.com/scrapy/scrapy/issues/7836),
  [#7838](https://github.com/scrapy/scrapy/issues/7838),
  [#7841](https://github.com/scrapy/scrapy/issues/7841),
  [#7844](https://github.com/scrapy/scrapy/issues/7844),
  [#7848](https://github.com/scrapy/scrapy/issues/7848),
  [#7853](https://github.com/scrapy/scrapy/issues/7853),
  [#7854](https://github.com/scrapy/scrapy/issues/7854),
  [#7857](https://github.com/scrapy/scrapy/issues/7857),
  [#7859](https://github.com/scrapy/scrapy/issues/7859),
  [#7863](https://github.com/scrapy/scrapy/issues/7863),
  [#7895](https://github.com/scrapy/scrapy/issues/7895),
  [#7906](https://github.com/scrapy/scrapy/issues/7906),
  [#7928](https://github.com/scrapy/scrapy/issues/7928),
  [#7935](https://github.com/scrapy/scrapy/issues/7935),
  [#7966](https://github.com/scrapy/scrapy/issues/7966),
  [#7968](https://github.com/scrapy/scrapy/issues/7968),
  [#7974](https://github.com/scrapy/scrapy/issues/7974),
  [#7979](https://github.com/scrapy/scrapy/issues/7979),
  [#7985](https://github.com/scrapy/scrapy/issues/7985),
  [#7990](https://github.com/scrapy/scrapy/issues/7990),
  [#7993](https://github.com/scrapy/scrapy/issues/7993),
  [#7995](https://github.com/scrapy/scrapy/issues/7995),
  [#8000](https://github.com/scrapy/scrapy/issues/8000),
  [#8001](https://github.com/scrapy/scrapy/issues/8001),
  [#8002](https://github.com/scrapy/scrapy/issues/8002))

## 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`](topics/download-handlers.md)
  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](https://github.com/scrapy/scrapy/security/advisories/GHSA-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`](topics/settings.md) and/or
  [`DOWNLOAD_TLS_MAX_VERSION`](topics/settings.md) settings instead if you want to change
  the TLS method selection.
  ([#3288](https://github.com/scrapy/scrapy/issues/3288), [#6546](https://github.com/scrapy/scrapy/issues/6546))
- The following spider attributes are deprecated in favor of settings:
  - `http_user` (use [`HTTPAUTH_USER`](topics/downloader-middleware.md))
  - `http_pass` (use [`HTTPAUTH_PASS`](topics/downloader-middleware.md))
  - `http_auth_domain` (use [`HTTPAUTH_DOMAIN`](topics/downloader-middleware.md))

  ([#7590](https://github.com/scrapy/scrapy/issues/7590))
- The `scrapy.commands.ScrapyCommand.help()` method is deprecated. It was
  never called by Scrapy.
  ([#7626](https://github.com/scrapy/scrapy/issues/7626), [#7633](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/6546), [#7619](https://github.com/scrapy/scrapy/issues/7619), [#7665](https://github.com/scrapy/scrapy/issues/7665))
- The `CRAWLSPIDER_FOLLOW_LINKS` setting is deprecated. You can set
  `follow=False` in your rules to achieve the same effect.
  ([#7592](https://github.com/scrapy/scrapy/issues/7592))
- Instantiating
  [`HttpCompressionMiddleware`](topics/downloader-middleware.md)
  without a `crawler` argument is deprecated.
  ([#7655](https://github.com/scrapy/scrapy/issues/7655))
- Instantiating
  [`RefererMiddleware`](topics/spider-middleware.md) without a
  `settings` argument is deprecated.
  ([#7664](https://github.com/scrapy/scrapy/issues/7664))

### New features

- Added support for HTTP/2 requests to
  [`HttpxDownloadHandler`](topics/download-handlers.md). It
  requires setting the new [`HTTPX_HTTP2_ENABLED`](topics/download-handlers.md) setting to
  `True`.
  ([#7575](https://github.com/scrapy/scrapy/issues/7575))
- Added support for SOCKS proxies to
  [`HttpxDownloadHandler`](topics/download-handlers.md).
  ([#747](https://github.com/scrapy/scrapy/issues/747), [#7575](https://github.com/scrapy/scrapy/issues/7575))
- Added [`DOWNLOAD_TLS_MIN_VERSION`](topics/settings.md) and
  [`DOWNLOAD_TLS_MAX_VERSION`](topics/settings.md) settings as replacements for the
  `DOWNLOADER_CLIENT_TLS_METHOD` setting (which is now deprecated).
  Compared to the old setting, they support specifying a range of allowed
  versions and support newer TLS versions.
  ([#4821](https://github.com/scrapy/scrapy/issues/4821), [#6546](https://github.com/scrapy/scrapy/issues/6546))
- Added [`HTTPAUTH_USER`](topics/downloader-middleware.md), [`HTTPAUTH_PASS`](topics/downloader-middleware.md) and
  [`HTTPAUTH_DOMAIN`](topics/downloader-middleware.md) settings and [`http_user`](topics/request-response.md),
  [`http_pass`](topics/request-response.md) and [`http_auth_domain`](topics/request-response.md) meta keys as more
  flexible ways to set HTTP authentication data.
  ([#7590](https://github.com/scrapy/scrapy/issues/7590))
- Added a [`verbatim_url`](topics/request-response.md) meta key that can be set to `True` to
  skip request URL canonicalization.
  ([#7473](https://github.com/scrapy/scrapy/issues/7473))
- Added `deny_tags` and `deny_attrs` arguments to [`LinkExtractor`](topics/link-extractors.md).
  ([#6321](https://github.com/scrapy/scrapy/issues/6321), [#7679](https://github.com/scrapy/scrapy/issues/7679))
- [`scrapy.Item.fields`](topics/items.md) now returns the fields in the definition order
  instead of the alphabetical one.
  ([#7015](https://github.com/scrapy/scrapy/issues/7015), [#7694](https://github.com/scrapy/scrapy/issues/7694))
- Added a [`RETRY_GIVE_UP_LOG_LEVEL`](topics/downloader-middleware.md) setting, a
  [`give_up_log_level`](topics/request-response.md) meta key and a `give_up_log_level` argument
  of the
  [`get_retry_request()`](topics/downloader-middleware.md) function that
  allow changing the log level of the message logged when the retry limit has
  been reached.
  ([#4622](https://github.com/scrapy/scrapy/issues/4622), [#5297](https://github.com/scrapy/scrapy/issues/5297), [#7567](https://github.com/scrapy/scrapy/issues/7567))
- It’s now possible to set [`DOWNLOADER_CLIENT_TLS_CIPHERS`](topics/settings.md) to
  `None` to use the default ciphers of the underlying TLS implementation.
  ([#7499](https://github.com/scrapy/scrapy/issues/7499), [#7665](https://github.com/scrapy/scrapy/issues/7665))

### Improvements

- [`FormRequest`](topics/request-response.md) is no longer deprecated, only its
  `from_response()` method is still deprecated.
  ([#7561](https://github.com/scrapy/scrapy/issues/7561), [#7671](https://github.com/scrapy/scrapy/issues/7671))
- Switched the item definition in the default project template from a
  [`scrapy.item.Item`](topics/items.md) to a dataclass.
  ([#7493](https://github.com/scrapy/scrapy/issues/7493), [#7513](https://github.com/scrapy/scrapy/issues/7513))
- Fixed deprecation warnings with pyOpenSSL 26.3.0.
  ([#7619](https://github.com/scrapy/scrapy/issues/7619))
- Removed the runtime warnings for [`Spider.allowed_domains`](topics/spiders.md) 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](https://scrapy-lint.readthedocs.io/en/latest/index.html) to find mistakes in your spider code
  instead.
  ([#4421](https://github.com/scrapy/scrapy/issues/4421), [#7627](https://github.com/scrapy/scrapy/issues/7627))
- `scrapy.utils.test.get_crawler()` now disables
  [`TELNETCONSOLE_ENABLED`](topics/settings.md) by default.
  ([#7644](https://github.com/scrapy/scrapy/issues/7644))
- Other code refactoring and improvements.
  ([#7409](https://github.com/scrapy/scrapy/issues/7409), [#7593](https://github.com/scrapy/scrapy/issues/7593), [#7594](https://github.com/scrapy/scrapy/issues/7594), [#7611](https://github.com/scrapy/scrapy/issues/7611), [#7649](https://github.com/scrapy/scrapy/issues/7649))

### Bug fixes

- [`HttpxDownloadHandler`](topics/download-handlers.md) no
  longer ignores proxy credentials for redirected or retried requests.
  ([#7601](https://github.com/scrapy/scrapy/issues/7601), [#7630](https://github.com/scrapy/scrapy/issues/7630))
- [`GCSFeedStorage`](topics/feed-exports.md) now closes the
  temporary file after the upload.
  ([#7546](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7552), [#7557](https://github.com/scrapy/scrapy/issues/7557))
- The [`IMAGES_STORE_S3_ACL`](topics/media-pipeline.md) and [`IMAGES_STORE_GCS_ACL`](topics/media-pipeline.md)
  settings are no longer ignored. This bug was introduced in Scrapy 2.12.0.
  ([#7597](https://github.com/scrapy/scrapy/issues/7597), [#7614](https://github.com/scrapy/scrapy/issues/7614))
- [`FTPDownloadHandler`](topics/download-handlers.md) now closes
  the connection after making the request.
  ([#7602](https://github.com/scrapy/scrapy/issues/7602), [#7667](https://github.com/scrapy/scrapy/issues/7667))
- Removed the deprecated `spider` argument from the pipeline defined in the
  default project template.
  ([#7676](https://github.com/scrapy/scrapy/issues/7676))
- Fixed `scrapy genspider --edit` not working.
  ([#7260](https://github.com/scrapy/scrapy/issues/7260), [#7683](https://github.com/scrapy/scrapy/issues/7683))
- When a [`Crawler`](topics/api.md) 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`](topics/api.md) instance were used.
  ([#1280](https://github.com/scrapy/scrapy/issues/1280), [#7647](https://github.com/scrapy/scrapy/issues/7647))
- Fixed several issues with cookie handling in
  `scrapy.utils.request.request_to_curl()`.
  ([#7603](https://github.com/scrapy/scrapy/issues/7603), [#7675](https://github.com/scrapy/scrapy/issues/7675), [#7684](https://github.com/scrapy/scrapy/issues/7684))
- Fixed `scrapy.resolver.CachingThreadedResolver` not disabling the
  cache when [`DNSCACHE_ENABLED`](topics/settings.md) is set to `False`.
  ([#7663](https://github.com/scrapy/scrapy/issues/7663))
- Fixed [`scrapy.utils.response.open_in_browser()`](topics/debug.md) not removing comments
  when looking for the `<base>` tag.
  ([#7506](https://github.com/scrapy/scrapy/issues/7506))
- Fixed checking for deprecated methods in custom [`ITEM_PROCESSOR`](topics/settings.md)
  implementations.
  ([#7589](https://github.com/scrapy/scrapy/issues/7589))
- Fixed `scrapy.utils.url.strip_url()` corrupting some URLs with
  credentials.
  ([#7604](https://github.com/scrapy/scrapy/issues/7604), [#7605](https://github.com/scrapy/scrapy/issues/7605))
- `scrapy.utils.misc.rel_has_nofollow()` now ignores the case when
  looking for “nofollow” strings.
  ([#7632](https://github.com/scrapy/scrapy/issues/7632))
- Fixed an exception in `scrapy.utils.sitemap.Sitemap` when parsing
  some malformed sitemaps.
  ([#7686](https://github.com/scrapy/scrapy/issues/7686), [#7687](https://github.com/scrapy/scrapy/issues/7687))

### Documentation

- Mentioned [scrapy-lint](https://scrapy-lint.readthedocs.io/en/latest/index.html) in the docs.
  ([#4421](https://github.com/scrapy/scrapy/issues/4421), [#7627](https://github.com/scrapy/scrapy/issues/7627))
- Added the docs about [security considerations](topics/security.md).
  ([#7389](https://github.com/scrapy/scrapy/issues/7389), [#7678](https://github.com/scrapy/scrapy/issues/7678))
- Improved the [item pipeline docs](topics/item-pipeline.md).
  ([#2350](https://github.com/scrapy/scrapy/issues/2350), [#7676](https://github.com/scrapy/scrapy/issues/7676))
- Documented which stats are collected by
  [`CoreStats`](topics/extensions.md).
  ([#7421](https://github.com/scrapy/scrapy/issues/7421))
- Switched documentation examples from using [`scrapy.item.Item`](topics/items.md) to
  using dataclasses.
  ([#7493](https://github.com/scrapy/scrapy/issues/7493), [#7513](https://github.com/scrapy/scrapy/issues/7513))
- Added feature comparison tables to the [download handler](topics/download-handlers.md "Built-in HTTP download handlers reference") docs.
  ([#7575](https://github.com/scrapy/scrapy/issues/7575))
- Improved the docs for [logging settings](topics/settings.md).
  ([#6909](https://github.com/scrapy/scrapy/issues/6909), [#7668](https://github.com/scrapy/scrapy/issues/7668))
- Documented a way to [improve startup time and memory usage](topics/practices.md "Reducing startup time in large projects") by using [`SPIDER_MODULES`](topics/settings.md).
  ([#7576](https://github.com/scrapy/scrapy/issues/7576), [#7600](https://github.com/scrapy/scrapy/issues/7600))
- Clarified handling of the `type` argument of [`Selector`](topics/selectors.md).
  ([#7704](https://github.com/scrapy/scrapy/issues/7704))
- Other documentation improvements and fixes.
  ([#4954](https://github.com/scrapy/scrapy/issues/4954),
  [#6120](https://github.com/scrapy/scrapy/issues/6120),
  [#7286](https://github.com/scrapy/scrapy/issues/7286),
  [#7564](https://github.com/scrapy/scrapy/issues/7564),
  [#7573](https://github.com/scrapy/scrapy/issues/7573),
  [#7598](https://github.com/scrapy/scrapy/issues/7598),
  [#7599](https://github.com/scrapy/scrapy/issues/7599),
  [#7698](https://github.com/scrapy/scrapy/issues/7698))

### Quality assurance

- Fixed deprecation warnings with pytest 9.1.0.
  ([#7621](https://github.com/scrapy/scrapy/issues/7621))
- Type hints improvements and fixes.
  ([#6958](https://github.com/scrapy/scrapy/issues/6958), [#7586](https://github.com/scrapy/scrapy/issues/7586))
- CI and test improvements and fixes.
  ([#5954](https://github.com/scrapy/scrapy/issues/5954),
  [#7002](https://github.com/scrapy/scrapy/issues/7002),
  [#7017](https://github.com/scrapy/scrapy/issues/7017),
  [#7247](https://github.com/scrapy/scrapy/issues/7247),
  [#7508](https://github.com/scrapy/scrapy/issues/7508),
  [#7545](https://github.com/scrapy/scrapy/issues/7545),
  [#7566](https://github.com/scrapy/scrapy/issues/7566),
  [#7574](https://github.com/scrapy/scrapy/issues/7574),
  [#7585](https://github.com/scrapy/scrapy/issues/7585),
  [#7595](https://github.com/scrapy/scrapy/issues/7595),
  [#7608](https://github.com/scrapy/scrapy/issues/7608),
  [#7610](https://github.com/scrapy/scrapy/issues/7610),
  [#7612](https://github.com/scrapy/scrapy/issues/7612),
  [#7616](https://github.com/scrapy/scrapy/issues/7616),
  [#7625](https://github.com/scrapy/scrapy/issues/7625),
  [#7637](https://github.com/scrapy/scrapy/issues/7637),
  [#7639](https://github.com/scrapy/scrapy/issues/7639),
  [#7640](https://github.com/scrapy/scrapy/issues/7640),
  [#7641](https://github.com/scrapy/scrapy/issues/7641),
  [#7642](https://github.com/scrapy/scrapy/issues/7642),
  [#7643](https://github.com/scrapy/scrapy/issues/7643),
  [#7644](https://github.com/scrapy/scrapy/issues/7644),
  [#7645](https://github.com/scrapy/scrapy/issues/7645),
  [#7646](https://github.com/scrapy/scrapy/issues/7646),
  [#7654](https://github.com/scrapy/scrapy/issues/7654),
  [#7655](https://github.com/scrapy/scrapy/issues/7655),
  [#7664](https://github.com/scrapy/scrapy/issues/7664),
  [#7672](https://github.com/scrapy/scrapy/issues/7672),
  [#7677](https://github.com/scrapy/scrapy/issues/7677),
  [#7680](https://github.com/scrapy/scrapy/issues/7680),
  [#7682](https://github.com/scrapy/scrapy/issues/7682),
  [#7692](https://github.com/scrapy/scrapy/issues/7692))

## Scrapy 2.16.0 (2026-05-19)

Highlights:

- Official support for Python 3.14
- Support for Twisted 26.4.0+

### Modified requirements

- Increased the minimum versions of the following dependencies:
  - [service_identity](https://service-identity.readthedocs.io/en/stable/): 18.1.0 → 23.1.0

  ([#7347](https://github.com/scrapy/scrapy/issues/7347))
- Added support for Twisted 26.4.0+.
  ([#7347](https://github.com/scrapy/scrapy/issues/7347), [#7505](https://github.com/scrapy/scrapy/issues/7505), [#7520](https://github.com/scrapy/scrapy/issues/7520))
- Added support for Python 3.14.
  ([#6604](https://github.com/scrapy/scrapy/issues/6604), [#7460](https://github.com/scrapy/scrapy/issues/7460))

### Backward-incompatible changes

- The following classes and functions, intended for internal use by
  [`HTTP11DownloadHandler`](topics/download-handlers.md)
  and [`H2DownloadHandler`](topics/download-handlers.md), 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](https://github.com/scrapy/scrapy/issues/7496), [#7510](https://github.com/scrapy/scrapy/issues/7510))

### Deprecations

- `scrapy.FormRequest` is deprecated. You can use the [form2request](https://form2request.readthedocs.io/en/latest/index.html) library instead, see [Creating requests that submit HTML forms](topics/request-response.md).
  ([#6438](https://github.com/scrapy/scrapy/issues/6438))
- `scrapy.utils.python.MutableChain` is deprecated.
  ([#7504](https://github.com/scrapy/scrapy/issues/7504))

### Deprecation removals

- The `start_requests()` method of [`Spider`](topics/spiders.md), deprecated in
  2.13.0, is removed and no longer called. Use [`start()`](topics/spiders.md)
  instead, or both to maintain support for lower Scrapy versions.
  ([#7490](https://github.com/scrapy/scrapy/issues/7490))
- Support for `process_start_requests()` methods of [spider middlewares](topics/spider-middleware.md), deprecated in 2.13.0, is removed. Use
  [`process_start()`](topics/spider-middleware.md) instead,
  or both to maintain support for lower Scrapy versions.
  ([#7490](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7486))
- The following functions, deprecated in Scrapy 2.13.0, are removed, you
  should import them from [`w3lib.url`](https://w3lib.readthedocs.io/en/latest/w3lib.html#module-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](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7487))
- `scrapy.downloadermiddlewares.ajaxcrawl.AjaxCrawlMiddleware` and
  `scrapy.utils.url.escape_ajax()`, deprecated in Scrapy 2.13.0, are
  removed.
  ([#7487](https://github.com/scrapy/scrapy/issues/7487))
- The `__init__()` method of priority queue classes (see
  [`SCHEDULER_PRIORITY_QUEUE`](topics/settings.md)) now needs to support a keyword-only
  `start_queue_cls` parameter, not supporting it was deprecated in Scrapy
  2.13.0.
  ([#7487](https://github.com/scrapy/scrapy/issues/7487))
- `scrapy.spiders.init.InitSpider`, deprecated in Scrapy 2.13.0, is
  removed.
  ([#7487](https://github.com/scrapy/scrapy/issues/7487))

### New features

- New features and improvements for
  [`HttpxDownloadHandler`](topics/download-handlers.md):
  - Support for proxies.
  - Support for the [`download_latency`](topics/request-response.md) meta key.
  - Support for [`Response.certificate`](topics/request-response.md).
  - Default headers set by the `httpx` library are no longer added to
    requests.

  ([#7441](https://github.com/scrapy/scrapy/issues/7441), [#7524](https://github.com/scrapy/scrapy/issues/7524))
- [`HTTP11DownloadHandler`](topics/download-handlers.md) now
  skips HTTPS proxy certificate verification when the
  [`DOWNLOAD_VERIFY_CERTIFICATES`](topics/settings.md) setting is set to `False`.
  ([#7496](https://github.com/scrapy/scrapy/issues/7496))

### Improvements

- [`time.monotonic()`](https://docs.python.org/3/library/time.html#time.monotonic) is used instead of [`time.time()`](https://docs.python.org/3/library/time.html#time.time) to calculate
  elapsed time in various places.
  ([#7377](https://github.com/scrapy/scrapy/issues/7377))
- Improved extraction of the file extension from the URL in
  [`FilesPipeline`](topics/media-pipeline.md).
  ([#4225](https://github.com/scrapy/scrapy/issues/4225), [#7414](https://github.com/scrapy/scrapy/issues/7414))
- Other code refactoring and improvements.
  ([#7401](https://github.com/scrapy/scrapy/issues/7401))

### Bug fixes

- [`HTTP11DownloadHandler`](topics/download-handlers.md) 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](https://github.com/scrapy/scrapy/issues/7496))
- [`H2DownloadHandler`](topics/download-handlers.md) now
  raises an exception for requests with `http://` URLs instead of trying to
  connect, which is not supported by this handler.
  ([#7496](https://github.com/scrapy/scrapy/issues/7496))
- [`H2DownloadHandler`](topics/download-handlers.md) no longer
  adds the `:status` pseudo-header to [`Response.headers`](topics/request-response.md).
  ([#7441](https://github.com/scrapy/scrapy/issues/7441))
- Fixed [`scrapy.utils.response.open_in_browser()`](topics/debug.md) removing the `<head>`
  tag when adding the `<base>` tag.
  ([#7459](https://github.com/scrapy/scrapy/issues/7459))

### Documentation

- Documented that
  [`HTTP11DownloadHandler`](topics/download-handlers.md)
  doesn’t support HTTPS proxies for HTTPS destinations and that
  [`H2DownloadHandler`](topics/download-handlers.md) doesn’t
  support proxies at all.
  ([#7496](https://github.com/scrapy/scrapy/issues/7496))
- Added an example of using
  [`logging.handlers.TimedRotatingFileHandler`](https://docs.python.org/3/library/logging.handlers.html#logging.handlers.TimedRotatingFileHandler) to rotate Scrapy logs.
  ([#3628](https://github.com/scrapy/scrapy/issues/3628), [#7501](https://github.com/scrapy/scrapy/issues/7501))
- Added a `CITATION.cff` file.
  ([#7502](https://github.com/scrapy/scrapy/issues/7502), [#7519](https://github.com/scrapy/scrapy/issues/7519))
- Mentioned `DOWNLOADER_CLIENT_TLS_METHOD` in [Avoiding getting banned](topics/practices.md).
  ([#5232](https://github.com/scrapy/scrapy/issues/5232), [#7518](https://github.com/scrapy/scrapy/issues/7518))
- Other documentation improvements and fixes.
  ([#7417](https://github.com/scrapy/scrapy/issues/7417),
  [#7463](https://github.com/scrapy/scrapy/issues/7463),
  [#7472](https://github.com/scrapy/scrapy/issues/7472),
  [#7480](https://github.com/scrapy/scrapy/issues/7480),
  [#7489](https://github.com/scrapy/scrapy/issues/7489),
  [#7503](https://github.com/scrapy/scrapy/issues/7503),
  [#7507](https://github.com/scrapy/scrapy/issues/7507))

### Quality assurance

- Added tests that connect to [https://books.toscrape.com/](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](https://github.com/scrapy/scrapy/issues/7520))
- Type hints improvements and fixes.
  ([#7492](https://github.com/scrapy/scrapy/issues/7492), [#7532](https://github.com/scrapy/scrapy/issues/7532))
- CI and test improvements and fixes.
  ([#7441](https://github.com/scrapy/scrapy/issues/7441), [#7466](https://github.com/scrapy/scrapy/issues/7466), [#7491](https://github.com/scrapy/scrapy/issues/7491), [#7496](https://github.com/scrapy/scrapy/issues/7496))

## Scrapy 2.15.2 (2026-04-28)

### Bug fixes

- Fixed links in [https://docs.scrapy.org/llms.txt](https://docs.scrapy.org/llms.txt) ([#7467](https://github.com/scrapy/scrapy/issues/7467))

## 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](https://github.com/scrapy/scrapy/issues/7445), [#7450](https://github.com/scrapy/scrapy/issues/7450))
- Fixed [`scrapy.settings.BaseSettings.getwithbase()`](topics/api.md) 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()`](topics/api.md),
  was added that does that, and it is now used for [component priority
  dictionaries](topics/settings.md "Component priority dictionaries").
  ([#7426](https://github.com/scrapy/scrapy/issues/7426), [#7449](https://github.com/scrapy/scrapy/issues/7449))
- Documentation rendering improvements.
  ([#7452](https://github.com/scrapy/scrapy/issues/7452), [#7454](https://github.com/scrapy/scrapy/issues/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](topics/download-handlers.md "Built-in HTTP download handlers reference") now
  raise Scrapy-specific exceptions instead of implementation-specific ones,
  see [Exceptions raised by download handlers](topics/download-handlers.md). This can affect user code that
  handles downloader exceptions, such as `process_exception()` methods of
  custom [downloader middlewares](topics/downloader-middleware.md "Writing your own downloader middleware").
  ([#7208](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/2183), [#6369](https://github.com/scrapy/scrapy/issues/6369), [#7182](https://github.com/scrapy/scrapy/issues/7182))
- `Request` and `Response` objects: `__slots__` and setter changes:
  - `scrapy.http.Request` and [`scrapy.http.Response`](topics/request-response.md) 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](https://github.com/scrapy/scrapy/issues/7036), [#7367](https://github.com/scrapy/scrapy/issues/7367), [#7374](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7353))

### Deprecations

- `scrapy.mail.MailSender` is deprecated. Please use [`smtplib`](https://docs.python.org/3/library/smtplib.html#module-smtplib),
  [`twisted.mail.smtp`](https://docs.twisted.org/en/stable/api/twisted.mail.smtp.html) or other 3rd party email libraries.
  ([#7249](https://github.com/scrapy/scrapy/issues/7249), [#7263](https://github.com/scrapy/scrapy/issues/7263))
- The `scrapy.extensions.statsmailer.StatsMailer` extension is deprecated.
  You can instead implement your own notifications by handling the
  [`spider_closed`](topics/signals.md) signal.
  ([#7249](https://github.com/scrapy/scrapy/issues/7249), [#7263](https://github.com/scrapy/scrapy/issues/7263))
- The `MEMUSAGE_NOTIFY_MAIL` setting is deprecated. You can instead
  implement your own notifications by handling the
  [`memusage_warning_reached`](topics/signals.md) and [`spider_closed`](topics/signals.md) signals.
  ([#7249](https://github.com/scrapy/scrapy/issues/7249), [#7263](https://github.com/scrapy/scrapy/issues/7263))
- The `DNS_RESOLVER` setting was renamed to [`TWISTED_DNS_RESOLVER`](topics/settings.md)
  and the old name is deprecated.
  ([#7350](https://github.com/scrapy/scrapy/issues/7350), [#7361](https://github.com/scrapy/scrapy/issues/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`](topics/settings.md) setting instead. If you
  cannot use the default context factory for some other reason, please
  subclass the [download handler](topics/download-handlers.md "Built-in HTTP download handlers reference") instead.
  ([#7352](https://github.com/scrapy/scrapy/issues/7352), [#7379](https://github.com/scrapy/scrapy/issues/7379))
- `scrapy.core.downloader.contextfactory.BrowserLikeContextFactory` is
  deprecated. You can set the new [`DOWNLOAD_VERIFY_CERTIFICATES`](topics/settings.md)
  setting to `True` instead.
  ([#7379](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7353), [#7391](https://github.com/scrapy/scrapy/issues/7391))
- Passing `str` instead of `bytes` to
  `scrapy.utils.sitemap.Sitemap` and
  `scrapy.utils.sitemap.sitemap_urls_from_robots()` is deprecated.
  ([#7007](https://github.com/scrapy/scrapy/issues/7007))
- `scrapy.utils.misc.walk_modules()` is deprecated. You can use
  `scrapy.utils.misc.walk_modules_iter()` instead.
  ([#7388](https://github.com/scrapy/scrapy/issues/7388))
- `scrapy.shell.Shell.inthread` is deprecated. You can use
  `scrapy.shell.Shell.fetch_available` instead to check if
  `fetch()` can be used.
  ([#7395](https://github.com/scrapy/scrapy/issues/7395))
- `scrapy.commands.ScrapyCommand.set_crawler()` is deprecated.
  ([#7276](https://github.com/scrapy/scrapy/issues/7276))

### New features

- Added an *experimental* mode for running Scrapy without installing a
  Twisted reactor: set [`TWISTED_REACTOR_ENABLED`](topics/settings.md) to `False` to
  enable it. This mode has limitations, refer to [its documentation](topics/asyncio.md "Using Scrapy without a Twisted reactor") for details. As long as it’s experimental, its
  behavior and related features and APIs may change in future Scrapy releases
  in a breaking way.
  ([#6219](https://github.com/scrapy/scrapy/issues/6219),
  [#7185](https://github.com/scrapy/scrapy/issues/7185),
  [#7186](https://github.com/scrapy/scrapy/issues/7186),
  [#7187](https://github.com/scrapy/scrapy/issues/7187),
  [#7188](https://github.com/scrapy/scrapy/issues/7188),
  [#7190](https://github.com/scrapy/scrapy/issues/7190),
  [#7197](https://github.com/scrapy/scrapy/issues/7197),
  [#7199](https://github.com/scrapy/scrapy/issues/7199),
  [#7209](https://github.com/scrapy/scrapy/issues/7209),
  [#7228](https://github.com/scrapy/scrapy/issues/7228),
  [#7355](https://github.com/scrapy/scrapy/issues/7355),
  [#7366](https://github.com/scrapy/scrapy/issues/7366),
  [#7385](https://github.com/scrapy/scrapy/issues/7385),
  [#7395](https://github.com/scrapy/scrapy/issues/7395))
- Added the [`scrapy.utils.reactorless.is_reactorless()`](topics/asyncio.md) function that
  checks if there is a running asyncio event loop but no Twisted reactor.
  ([#7185](https://github.com/scrapy/scrapy/issues/7185), [#7199](https://github.com/scrapy/scrapy/issues/7199))
- Changed [`scrapy.utils.asyncio.is_asyncio_available()`](topics/asyncio.md) to return
  `True` if there is a running asyncio loop, even if no Twisted reactor is
  installed.
  ([#7185](https://github.com/scrapy/scrapy/issues/7185), [#7199](https://github.com/scrapy/scrapy/issues/7199))
- Added an *experimental* download handler that uses the [httpx](https://www.python-httpx.org/) library and
  doesn’t require a Twisted reactor:
  [`HttpxDownloadHandler`](topics/download-handlers.md). As
  long as it’s experimental, its behavior may change in future Scrapy
  releases in a breaking way.
  ([#6805](https://github.com/scrapy/scrapy/issues/6805), [#7239](https://github.com/scrapy/scrapy/issues/7239), [#7368](https://github.com/scrapy/scrapy/issues/7368), [#7384](https://github.com/scrapy/scrapy/issues/7384))
- Added the [`DOWNLOAD_BIND_ADDRESS`](topics/settings.md) setting as a global counterpart
  to the per-request [`bindaddress`](topics/request-response.md) meta key.
  ([#7266](https://github.com/scrapy/scrapy/issues/7266), [#7283](https://github.com/scrapy/scrapy/issues/7283))
- Added the [`DOWNLOAD_VERIFY_CERTIFICATES`](topics/settings.md) setting that can be set
  to `True` to make Scrapy abort HTTPS requests when the server certificate
  is invalid or doesn’t match the domain.
  ([#7379](https://github.com/scrapy/scrapy/issues/7379))
- The built-in HTTP [download handlers](topics/download-handlers.md "Built-in HTTP download handlers reference") now
  raise Scrapy-specific exceptions instead of implementation-specific ones,
  to allow unified handling of similar problems caused by different
  implementations. The default value of the [`RETRY_EXCEPTIONS`](topics/downloader-middleware.md)
  setting was updated replacing Twisted-specific exceptions with these new
  ones. The exceptions:
  - [`CannotResolveHostError`](topics/download-handlers.md)
  - [`DownloadCancelledError`](topics/download-handlers.md)
  - [`DownloadConnectionRefusedError`](topics/download-handlers.md)
  - [`DownloadFailedError`](topics/download-handlers.md)
  - [`DownloadTimeoutError`](topics/download-handlers.md)
  - [`ResponseDataLossError`](topics/download-handlers.md)
  - [`UnsupportedURLSchemeError`](topics/download-handlers.md)

  ([#7208](https://github.com/scrapy/scrapy/issues/7208))
- Added the [`memusage_warning_reached`](topics/signals.md) signal emitted by the
  [`MemoryUsage`](topics/extensions.md) extension when the memory
  usage reaches [`MEMUSAGE_WARNING_MB`](topics/settings.md).
  ([#7249](https://github.com/scrapy/scrapy/issues/7249), [#7263](https://github.com/scrapy/scrapy/issues/7263))
- Added
  `Headers.to_tuple_list()`
  that returns headers as a list of `(key, value)` tuples.
  ([#7239](https://github.com/scrapy/scrapy/issues/7239))
- [`S3DownloadHandler`](topics/download-handlers.md) now uses the
  download handler configured for the `"https"` scheme to make requests
  instead of always using
  [`HTTP11DownloadHandler`](topics/download-handlers.md).
  ([#7369](https://github.com/scrapy/scrapy/issues/7369), [#7370](https://github.com/scrapy/scrapy/issues/7370))
- Added `scrapy.utils.misc.walk_modules_iter()` as a replacement for
  `scrapy.utils.misc.walk_modules()` that returns an iterable instead of a
  list.
  ([#7388](https://github.com/scrapy/scrapy/issues/7388))

### Improvements

- [`asyncio.to_thread()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread) is now used instead of
  [`twisted.internet.threads.deferToThread()`](https://docs.twisted.org/en/stable/api/twisted.internet.threads.html#deferToThread) in the built-in feed
  storages, media pipeline storages and the
  `scrapy.utils.decorators.inthread()` decorator when available.
  ([#7183](https://github.com/scrapy/scrapy/issues/7183), [#7184](https://github.com/scrapy/scrapy/issues/7184), [#7349](https://github.com/scrapy/scrapy/issues/7349))
- Improved memory footprint of [`Request`](topics/request-response.md) and
  [`Response`](topics/request-response.md) objects by adding `__slots__` and omitting
  empty lists and dicts in some internal attributes.
  ([#7036](https://github.com/scrapy/scrapy/issues/7036), [#7367](https://github.com/scrapy/scrapy/issues/7367), [#7374](https://github.com/scrapy/scrapy/issues/7374))
- `_ScrapyClientContextFactory`
  no longer mutates the SSL context, to avoid the behavior that was
  deprecated in pyOpenSSL 25.1.0.
  ([#6859](https://github.com/scrapy/scrapy/issues/6859), [#7353](https://github.com/scrapy/scrapy/issues/7353))
- Improved memory usage of [`SitemapSpider`](topics/spiders.md) and
  `scrapy.utils.sitemap.Sitemap`.
  ([#3529](https://github.com/scrapy/scrapy/issues/3529), [#7007](https://github.com/scrapy/scrapy/issues/7007))
- Improved the scheduling behavior of
  [`DownloaderAwarePriorityQueue`](topics/scheduler.md) when crawling
  multiple domains.
  ([#7293](https://github.com/scrapy/scrapy/issues/7293), [#7351](https://github.com/scrapy/scrapy/issues/7351))
- [`HTTP11DownloadHandler`](topics/download-handlers.md) and
  [`H2DownloadHandler`](topics/download-handlers.md) now handle
  TLS verbose logging (see [`DOWNLOADER_CLIENT_TLS_VERBOSE_LOGGING`](topics/settings.md))
  directly instead of relying on
  `_ScrapyClientContextFactory`.
  ([#7387](https://github.com/scrapy/scrapy/issues/7387))
- The server certificate verification code now correctly handles certificates
  with IP addresses in `subjectAltName`.
  ([#7353](https://github.com/scrapy/scrapy/issues/7353))
- Improved reliability of [`scrapy.utils.trackref.get_oldest()`](topics/leaks.md).
  ([#1758](https://github.com/scrapy/scrapy/issues/1758), [#7375](https://github.com/scrapy/scrapy/issues/7375))
- Other code refactoring and improvements.
  ([#7210](https://github.com/scrapy/scrapy/issues/7210), [#7238](https://github.com/scrapy/scrapy/issues/7238), [#7376](https://github.com/scrapy/scrapy/issues/7376), [#7386](https://github.com/scrapy/scrapy/issues/7386), [#7395](https://github.com/scrapy/scrapy/issues/7395),
  [#7405](https://github.com/scrapy/scrapy/issues/7405), [#7410](https://github.com/scrapy/scrapy/issues/7410))

### Bug fixes

- [Media pipelines](topics/media-pipeline.md) should now wait for uploads
  to asynchronous storages (e.g.
  `S3FilesStore`) to complete.
  ([#2183](https://github.com/scrapy/scrapy/issues/2183), [#6369](https://github.com/scrapy/scrapy/issues/6369), [#7182](https://github.com/scrapy/scrapy/issues/7182))
- Fixed merging `*_BASE` settings (e.g. merging
  [`DOWNLOADER_MIDDLEWARES`](topics/settings.md) with
  [`DOWNLOADER_MIDDLEWARES_BASE`](topics/settings.md)) when a component is referred to by
  a class object in one setting and by a string import path in the other one.
  ([#6912](https://github.com/scrapy/scrapy/issues/6912), [#6993](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/6820), [#7255](https://github.com/scrapy/scrapy/issues/7255))
- Fixed repeated warnings about data loss (see
  [`DOWNLOAD_FAIL_ON_DATALOSS`](topics/settings.md)) not being suppressed in
  [`HTTP11DownloadHandler`](topics/download-handlers.md).
  ([#7222](https://github.com/scrapy/scrapy/issues/7222))
- Improved FTP connection management in
  `scrapy.pipelines.files.FTPFilesStore`.
  ([#7256](https://github.com/scrapy/scrapy/issues/7256))
- Fixed the `spider` variable in the [shell](topics/shell.md), which
  wasn’t available since Scrapy 2.13.0.
  ([#7395](https://github.com/scrapy/scrapy/issues/7395))

### Documentation

- The `llms.txt` and `llms-full.txt` files and Markdown versions of pages
  are now generated when the HTML documentation is built.
  ([#7380](https://github.com/scrapy/scrapy/issues/7380))
- Added a “Copy as Markdown” button to the HTML documentation.
  ([#7380](https://github.com/scrapy/scrapy/issues/7380))
- Added [docs for using Pydantic models as items](topics/items.md "Pydantic models").
  ([#6955](https://github.com/scrapy/scrapy/issues/6955), [#6966](https://github.com/scrapy/scrapy/issues/6966))
- Documented [job directory contents](topics/jobs.md).
  ([#4842](https://github.com/scrapy/scrapy/issues/4842), [#5260](https://github.com/scrapy/scrapy/issues/5260))
- Improved docs for [`dont_filter`](topics/request-response.md).
  ([#6398](https://github.com/scrapy/scrapy/issues/6398), [#7245](https://github.com/scrapy/scrapy/issues/7245))
- Clarified that settings related to [`TWISTED_DNS_RESOLVER`](topics/settings.md) are only
  taken into account if the selected resolver supports them.
  ([#7385](https://github.com/scrapy/scrapy/issues/7385))
- Other documentation improvements and fixes.
  ([#7248](https://github.com/scrapy/scrapy/issues/7248), [#7274](https://github.com/scrapy/scrapy/issues/7274), [#7406](https://github.com/scrapy/scrapy/issues/7406), [#7408](https://github.com/scrapy/scrapy/issues/7408))

### Quality assurance

- Added the `no-reactor` test environment that doesn’t install a Twisted
  reactor and uses `pytest-asyncio` instead of `pytest-twisted` to run
  asynchronous test functions.
  ([#6952](https://github.com/scrapy/scrapy/issues/6952), [#7189](https://github.com/scrapy/scrapy/issues/7189), [#7233](https://github.com/scrapy/scrapy/issues/7233), [#7234](https://github.com/scrapy/scrapy/issues/7234), [#7254](https://github.com/scrapy/scrapy/issues/7254),
  [#7259](https://github.com/scrapy/scrapy/issues/7259))
- Fixed running tests with `pytest-xdist`.
  ([#7216](https://github.com/scrapy/scrapy/issues/7216), [#7257](https://github.com/scrapy/scrapy/issues/7257))
- Type hints improvements and fixes.
  ([#7300](https://github.com/scrapy/scrapy/issues/7300), [#7331](https://github.com/scrapy/scrapy/issues/7331))
- CI and test improvements and fixes.
  ([#7060](https://github.com/scrapy/scrapy/issues/7060),
  [#7223](https://github.com/scrapy/scrapy/issues/7223),
  [#7232](https://github.com/scrapy/scrapy/issues/7232),
  [#7241](https://github.com/scrapy/scrapy/issues/7241),
  [#7250](https://github.com/scrapy/scrapy/issues/7250),
  [#7256](https://github.com/scrapy/scrapy/issues/7256),
  [#7276](https://github.com/scrapy/scrapy/issues/7276),
  [#7277](https://github.com/scrapy/scrapy/issues/7277),
  [#7279](https://github.com/scrapy/scrapy/issues/7279),
  [#7329](https://github.com/scrapy/scrapy/issues/7329),
  [#7363](https://github.com/scrapy/scrapy/issues/7363),
  [#7381](https://github.com/scrapy/scrapy/issues/7381),
  [#7402](https://github.com/scrapy/scrapy/issues/7402))

## 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](https://github.com/scrapy/scrapy/security/advisories/GHSA-cwxj-rr6w-m6w7) security advisory
  for details.
- In line with the [standard](https://fetch.spec.whatwg.org/#http-redirect-fetch), 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`](topics/request-response.md) 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`](topics/spider-middleware.md), to allow customizing
  supported referrer policies.

### Bug fixes

- Made additional redirect scenarios convert to `GET` in line with the
  [standard](https://fetch.spec.whatwg.org/#http-redirect-fetch):
  - 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](https://github.com/scrapy-plugins/scrapy-playwright) or [scrapy-zyte-api](https://scrapy-zyte-api.readthedocs.io/en/latest/), while letting Scrapy
  handle redirects.
- The `Referer` header is now removed on redirect if
  [`RefererMiddleware`](topics/spider-middleware.md) 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](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7213))

### Quality assurance

- Replaced deprecated `codecov/test-results-action@v1` GitHub Action with
  `codecov/codecov-action@v5`.
  ([#7180](https://github.com/scrapy/scrapy/issues/7180), [#7215](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7121))
- Dropped support for PyPy 3.10.
  ([#7050](https://github.com/scrapy/scrapy/issues/7050))
- Increased the minimum versions of the following dependencies:
  - [lxml](https://lxml.de/): 4.6.0 → 4.6.4
  - [Pillow](https://github.com/python-pillow/Pillow) (optional dependency): 8.0.0 → 8.3.2
  - [botocore](https://github.com/boto/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](https://github.com/scrapy/scrapy/issues/7160))

### Backward-incompatible changes

- If you set the `TWISTED_REACTOR` setting to a non-asyncio
  value at the [spider level](topics/settings.md "2. Spider settings"), you
  may now need to set the `FORCE_CRAWLER_PROCESS` setting to
  `True` when running Scrapy via [its command-line tool](topics/commands.md "Commands that run a crawl") to avoid a reactor mismatch exception.
  ([#6845](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7046))
- The classes listed below are now [abstract base classes](https://docs.python.org/3/glossary.html#term-abstract-base-class). 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`](topics/commands.md)
    > - [`run()`](topics/commands.md)
    > - [`short_desc()`](topics/commands.md)
  - [`scrapy.exporters.BaseItemExporter`](topics/exporters.md)
    > - [`export_item()`](topics/exporters.md)
  - [`scrapy.extensions.feedexport.BlockingFeedStorage`](topics/feed-exports.md)
    > - [`_store_in_thread()`](topics/feed-exports.md)
  - `scrapy.middleware.MiddlewareManager`
    > - `_get_mwlist_from_settings()`
  - [`scrapy.spidermiddlewares.referer.ReferrerPolicy`](topics/spider-middleware.md)
    > - `referrer()`

  ([#6930](https://github.com/scrapy/scrapy/issues/6930))
- Scrapy no longer passes a `spider` argument to any methods of the
  [`stats collector`](topics/settings.md). 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`](topics/spiders.md) instance, you can get it
  from the [`Crawler`](topics/api.md) instance passed to the
  constructor.
  ([#7011](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7006))
- `scrapy.downloadermiddlewares.robotstxt.RobotsTxtMiddleware.process_request()`
  now returns a coroutine, previously it returned a
  [`Deferred`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.Deferred.html) object or `None`. The
  `robot_parser()` method was also changed to return a coroutine. This
  change only impacts code that subclasses
  [`RobotsTxtMiddleware`](topics/downloader-middleware.md) or
  calls its methods directly.
  ([#6802](https://github.com/scrapy/scrapy/issues/6802))
- The built-in [download handlers](topics/download-handlers.md "Built-in HTTP download handlers reference") 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](https://github.com/scrapy/scrapy/issues/6778), [#7164](https://github.com/scrapy/scrapy/issues/7164))
- `scrapy.pipelines.media.MediaPipeline.process_item()` now returns a
  coroutine, previously it returned a
  [`Deferred`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.Deferred.html) object. This
  change only impacts code that calls this method directly.
  ([#7177](https://github.com/scrapy/scrapy/issues/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.
  - [`scrapy.dupefilters.RFPDupeFilter`](topics/settings.md)
  - `scrapy.mail.MailSender`
  - `scrapy.middleware.MiddlewareManager`
  - `scrapy.core.downloader.contextfactory.ScrapyClientContextFactory`
  - [`scrapy.pipelines.files.FilesPipeline`](topics/media-pipeline.md)
  - [`scrapy.pipelines.images.ImagesPipeline`](topics/media-pipeline.md)

  ([#7126](https://github.com/scrapy/scrapy/issues/7126))
- Scrapy no longer calls `from_settings()` methods of 3rd-party
  [components](topics/components.md), deprecated in Scrapy 2.12.0. You
  should define a `from_crawler()` method instead.
  ([#7126](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7126))
- The `REQUEST_FINGERPRINTER_IMPLEMENTATION` setting, deprecated in Scrapy
  2.12.0, is removed.
  ([#7126](https://github.com/scrapy/scrapy/issues/7126))
- The `scrapy.utils.misc.create_instance()` function, deprecated in Scrapy
  2.12.0, is removed. Use [`scrapy.utils.misc.build_from_crawler()`](topics/components.md)
  instead.
  ([#7126](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7126))
- The `scrapy.twisted_version` attribute, deprecated in Scrapy 2.12.0, is
  removed. You should instead use the `twisted.version` attribute
  directly.
  ([#7126](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7126))
- `scrapy.utils.serialize.ScrapyJSONDecoder`, deprecated in Scrapy 2.12.0,
  is removed.
  ([#7126](https://github.com/scrapy/scrapy/issues/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](https://github.com/scrapy/scrapy/issues/7126))
- `scrapy.spidermiddlewares.offsite.OffsiteMiddleware`, deprecated in
  Scrapy 2.11.2, is removed.
  [`scrapy.downloadermiddlewares.offsite.OffsiteMiddleware`](topics/downloader-middleware.md) should be
  used instead.
  ([#6926](https://github.com/scrapy/scrapy/issues/6926))

### Deprecations

- The following methods that return a
  [`Deferred`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.Deferred.html) 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`](topics/api.md)
    > - `start()` (use
    >   [`start_async()`](topics/api.md))
    > - `stop()` (use
    >   [`stop_async()`](topics/api.md))
    > - `close()` (use
    >   `close_async()`)
    > - `open_spider()` (use
    >   [`open_spider_async()`](topics/api.md))
    > - `close_spider()` (use
    >   [`close_spider_async()`](topics/api.md))
    > - `download()` (use
    >   [`download_async()`](topics/api.md))
  - `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`](topics/api.md)
    > - `stop()` (use [`stop_async()`](topics/api.md))
  - `scrapy.pipelines.ItemPipelineManager`
    > - `process_item()` (use
    >   `process_item_async()`)
    > - `open_spider()` (use
    >   `open_spider_async()`)
    > - `close_spider()` (use
    >   `close_spider_async()`)
  - [`scrapy.signalmanager.SignalManager`](topics/api.md)
    > - `send_catch_log_deferred()` (use
    >   [`send_catch_log_async()`](topics/api.md))
  - `scrapy.utils.signal.send_catch_log_deferred()` (use
    `scrapy.utils.signal.send_catch_log_async()`)

  ([#6791](https://github.com/scrapy/scrapy/issues/6791), [#6842](https://github.com/scrapy/scrapy/issues/6842), [#6979](https://github.com/scrapy/scrapy/issues/6979), [#6997](https://github.com/scrapy/scrapy/issues/6997), [#6999](https://github.com/scrapy/scrapy/issues/6999),
  [#7005](https://github.com/scrapy/scrapy/issues/7005), [#7043](https://github.com/scrapy/scrapy/issues/7043), [#7069](https://github.com/scrapy/scrapy/issues/7069), [#7161](https://github.com/scrapy/scrapy/issues/7161), [#7164](https://github.com/scrapy/scrapy/issues/7164))
- The following spider attributes are deprecated in favor of settings:
  - `download_maxsize` (use [`DOWNLOAD_MAXSIZE`](topics/settings.md))
  - `download_timeout` (use [`DOWNLOAD_TIMEOUT`](topics/settings.md))
  - `download_warnsize` (use [`DOWNLOAD_WARNSIZE`](topics/settings.md))
  - `max_concurrent_requests` (use
    [`CONCURRENT_REQUESTS_PER_DOMAIN`](topics/settings.md))
  - `user_agent` (use [`USER_AGENT`](topics/settings.md))

  ([#6988](https://github.com/scrapy/scrapy/issues/6988), [#6994](https://github.com/scrapy/scrapy/issues/6994), [#7038](https://github.com/scrapy/scrapy/issues/7038), [#7039](https://github.com/scrapy/scrapy/issues/7039), [#7117](https://github.com/scrapy/scrapy/issues/7117),
  [#7176](https://github.com/scrapy/scrapy/issues/7176))
- Returning a [`Deferred`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.Deferred.html) 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](https://github.com/scrapy/scrapy/issues/6718), [#6778](https://github.com/scrapy/scrapy/issues/6778), [#7069](https://github.com/scrapy/scrapy/issues/7069), [#7147](https://github.com/scrapy/scrapy/issues/7147), [#7148](https://github.com/scrapy/scrapy/issues/7148),
  [#7149](https://github.com/scrapy/scrapy/issues/7149), [#7150](https://github.com/scrapy/scrapy/issues/7150), [#7151](https://github.com/scrapy/scrapy/issues/7151), [#7161](https://github.com/scrapy/scrapy/issues/7161), [#7164](https://github.com/scrapy/scrapy/issues/7164),
  [#7179](https://github.com/scrapy/scrapy/issues/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`](topics/stats.md)
  - `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](https://github.com/scrapy/scrapy/issues/6750), [#6927](https://github.com/scrapy/scrapy/issues/6927), [#6984](https://github.com/scrapy/scrapy/issues/6984), [#7006](https://github.com/scrapy/scrapy/issues/7006), [#7011](https://github.com/scrapy/scrapy/issues/7011),
  [#7033](https://github.com/scrapy/scrapy/issues/7033), [#7037](https://github.com/scrapy/scrapy/issues/7037), [#7045](https://github.com/scrapy/scrapy/issues/7045), [#7178](https://github.com/scrapy/scrapy/issues/7178))
- Instantiating subclasses of `scrapy.middleware.MiddlewareManager`
  without a [`Crawler`](topics/api.md) instance is deprecated.
  ([#6984](https://github.com/scrapy/scrapy/issues/6984))
- For the following user-defined functions and methods requiring a `spider`
  argument is deprecated, if you need a [`Spider`](topics/spiders.md) instance
  inside them you should get it from the [`Crawler`](topics/api.md)
  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`](topics/settings.md)

  ([#6927](https://github.com/scrapy/scrapy/issues/6927), [#6984](https://github.com/scrapy/scrapy/issues/6984), [#7006](https://github.com/scrapy/scrapy/issues/7006), [#7037](https://github.com/scrapy/scrapy/issues/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`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.Deferred.html) 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`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.Deferred.html) (you should refactor
    it to return a coroutine or add an empty one if you don’t have it)

  ([#6778](https://github.com/scrapy/scrapy/issues/6778), [#7164](https://github.com/scrapy/scrapy/issues/7164))
- Custom implementations of [`ITEM_PROCESSOR`](topics/settings.md) 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](https://github.com/scrapy/scrapy/issues/7005), [#7043](https://github.com/scrapy/scrapy/issues/7043))
- The `CONCURRENT_REQUESTS_PER_IP` setting is deprecated, use
  [`CONCURRENT_REQUESTS_PER_DOMAIN`](topics/settings.md) instead.
  ([#6917](https://github.com/scrapy/scrapy/issues/6917), [#6921](https://github.com/scrapy/scrapy/issues/6921))
- The `scrapy.core.downloader.handlers.http` module is deprecated. You
  should import
  [`scrapy.core.downloader.handlers.http11.HTTP11DownloadHandler`](topics/download-handlers.md)
  directly instead of importing the
  `scrapy.core.downloader.handlers.http.HTTPDownloadHandler` alias.
  ([#7079](https://github.com/scrapy/scrapy/issues/7079))
- The `scrapy.utils.decorators.defers()` decorator is deprecated, you can
  use [`twisted.internet.defer.maybeDeferred()`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.html#maybeDeferred) directly or reimplement
  this decorator in your code.
  ([#7164](https://github.com/scrapy/scrapy/issues/7164))
- `scrapy.spiders.CrawlSpider._parse_response()` is deprecated, use
  `scrapy.spiders.CrawlSpider.parse_with_rules()` instead.
  ([#4463](https://github.com/scrapy/scrapy/issues/4463), [#6804](https://github.com/scrapy/scrapy/issues/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()`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.html#maybeDeferred))
  - `scrapy.utils.defer.defer_succeed()` (you can use
    [`twisted.internet.defer.succeed()`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.html#succeed))
  - `scrapy.utils.defer.defer_fail()` (you can use
    [`twisted.internet.defer.fail()`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.html#fail))
  - `scrapy.utils.defer.defer_result()` (you can use
    [`twisted.internet.defer.succeed()`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.html#succeed) and
    [`twisted.internet.defer.fail()`](https://docs.twisted.org/en/stable/api/twisted.internet.defer.html#fail))

  ([#6937](https://github.com/scrapy/scrapy/issues/6937))

### New features

- Added [`scrapy.crawler.AsyncCrawlerProcess`](topics/api.md) and
  [`scrapy.crawler.AsyncCrawlerRunner`](topics/api.md) as counterparts to
  [`CrawlerProcess`](topics/api.md) and
  [`CrawlerRunner`](topics/api.md) that offer coroutine-based APIs.
  ([#6789](https://github.com/scrapy/scrapy/issues/6789), [#6790](https://github.com/scrapy/scrapy/issues/6790), [#6796](https://github.com/scrapy/scrapy/issues/6796), [#6817](https://github.com/scrapy/scrapy/issues/6817), [#6845](https://github.com/scrapy/scrapy/issues/6845),
  [#7034](https://github.com/scrapy/scrapy/issues/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`](topics/api.md)
    > - [`start_async()`](topics/api.md) (to
    >   `start()`)
    > - [`stop_async()`](topics/api.md) (to
    >   `stop()`)
    > - `close_async()` (to
    >   `close()`)
    > - [`open_spider_async()`](topics/api.md) (to
    >   `open_spider()`)
    > - [`close_spider_async()`](topics/api.md) (to
    >   `close_spider()`)
    > - [`download_async()`](topics/api.md) (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`](topics/api.md)
    > - [`crawl_async()`](topics/api.md) (to `crawl()`)
    > - [`stop_async()`](topics/api.md) (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`](topics/api.md)
    > - [`send_catch_log_async()`](topics/api.md) (to
    >   `send_catch_log_deferred()`)

  ([#6781](https://github.com/scrapy/scrapy/issues/6781), [#6791](https://github.com/scrapy/scrapy/issues/6791), [#6792](https://github.com/scrapy/scrapy/issues/6792), [#6795](https://github.com/scrapy/scrapy/issues/6795), [#6801](https://github.com/scrapy/scrapy/issues/6801),
  [#6817](https://github.com/scrapy/scrapy/issues/6817), [#6842](https://github.com/scrapy/scrapy/issues/6842), [#6997](https://github.com/scrapy/scrapy/issues/6997), [#7005](https://github.com/scrapy/scrapy/issues/7005), [#7043](https://github.com/scrapy/scrapy/issues/7043),
  [#7069](https://github.com/scrapy/scrapy/issues/7069),:gh:7164, [#7202](https://github.com/scrapy/scrapy/issues/7202))
- The default value of the [`SCHEDULER_PRIORITY_QUEUE`](topics/settings.md) setting is now
  `'scrapy.pqueues.DownloaderAwarePriorityQueue'`.
  ([#6924](https://github.com/scrapy/scrapy/issues/6924), [#6940](https://github.com/scrapy/scrapy/issues/6940))
- Added [`scrapy.extensions.logcount.LogCount`](topics/extensions.md), an enabled-by-default
  extension that is responsible for the `log_count/*` stats. Previously,
  this code was in [`scrapy.crawler.Crawler`](topics/api.md) and couldn’t be disabled.
  ([#7046](https://github.com/scrapy/scrapy/issues/7046))
- Added `scrapy.spiders.CrawlSpider.parse_with_rules()` as a public
  replacement for `_parse_response()`.
  ([#4463](https://github.com/scrapy/scrapy/issues/4463), [#6804](https://github.com/scrapy/scrapy/issues/6804))
- Added [`scrapy.utils.asyncio.is_asyncio_available()`](topics/asyncio.md) as an alternative
  to `scrapy.utils.reactor.is_asyncio_reactor_installed` with a
  future-proof name and semantics.
  ([#6827](https://github.com/scrapy/scrapy/issues/6827))
- The API for [download handlers](topics/download-handlers.md), previously
  undocumented, has been modernized and documented. An optional base class,
  [`scrapy.core.downloader.handlers.base.BaseDownloadHandler`](topics/download-handlers.md), has been
  added to simplify writing custom download handlers that conform to the
  current API.
  ([#4944](https://github.com/scrapy/scrapy/issues/4944), [#6778](https://github.com/scrapy/scrapy/issues/6778), [#7164](https://github.com/scrapy/scrapy/issues/7164))
- Added [`scrapy.utils.defer.ensure_awaitable()`](topics/asyncio.md), which can be helpful to
  call user-defined functions that can return coroutines, Deferreds or
  values directly.
  ([#7005](https://github.com/scrapy/scrapy/issues/7005))
- The `requests.seen` file, written by
  [`RFPDupeFilter`](topics/settings.md) when [job persistence](topics/jobs.md) is enabled, now uses line buffering to reduce data loss in
  spider crashes.
  ([#6019](https://github.com/scrapy/scrapy/issues/6019), [#7094](https://github.com/scrapy/scrapy/issues/7094))
- Images downloaded by [`ImagesPipeline`](topics/media-pipeline.md) are
  now automatically transposed based on EXIF data.
  ([#6525](https://github.com/scrapy/scrapy/issues/6525), [#6975](https://github.com/scrapy/scrapy/issues/6975))

### Improvements

- Refactored internal functions to use coroutines instead of Deferreds.
  ([#6795](https://github.com/scrapy/scrapy/issues/6795), [#6852](https://github.com/scrapy/scrapy/issues/6852), [#6855](https://github.com/scrapy/scrapy/issues/6855), [#6858](https://github.com/scrapy/scrapy/issues/6858), [#7159](https://github.com/scrapy/scrapy/issues/7159))
- Commands that don’t need a [`CrawlerProcess`](topics/api.md) instance
  no longer create it.
  ([#6824](https://github.com/scrapy/scrapy/issues/6824))
- Improved [`shell`](topics/commands.md) help formatting when using IPython 9+.
  ([#6915](https://github.com/scrapy/scrapy/issues/6915), [#6980](https://github.com/scrapy/scrapy/issues/6980))

### Bug fixes

- Setting [`FILES_STORE`](topics/media-pipeline.md) or [`IMAGES_STORE`](topics/media-pipeline.md) to `None` now
  correctly disables the respective pipeline.
  ([#6964](https://github.com/scrapy/scrapy/issues/6964), [#6969](https://github.com/scrapy/scrapy/issues/6969))
- [`MetaRefreshMiddleware`](topics/downloader-middleware.md) now
  uses the URL set in the `<base>` tag as the base URL when redirecting to
  a relative URL.
  ([#7042](https://github.com/scrapy/scrapy/issues/7042), [#7047](https://github.com/scrapy/scrapy/issues/7047))
- Passing `None` as a value of the [`download_slot`](topics/settings.md) request meta
  key is now handled in the same way as not setting this meta key at all.
  ([#7172](https://github.com/scrapy/scrapy/issues/7172))
- Fixed parsing of the first line of `robots.txt` files that have a BOM.
  ([#6195](https://github.com/scrapy/scrapy/issues/6195), [#7095](https://github.com/scrapy/scrapy/issues/7095))

### Documentation

- Added [documentation](topics/download-handlers.md) about download
  handlers, their API and built-in handlers.
  ([#4944](https://github.com/scrapy/scrapy/issues/4944), [#7164](https://github.com/scrapy/scrapy/issues/7164))
- Added a section about the [scrapy-spider-metadata](https://scrapy-spider-metadata.readthedocs.io/en/latest/) library to the
  [spider argument docs](topics/spiders.md "scrapy-spider-metadata parameters").
  ([#6676](https://github.com/scrapy/scrapy/issues/6676), [#6957](https://github.com/scrapy/scrapy/issues/6957), [#7116](https://github.com/scrapy/scrapy/issues/7116))
- Improved [the docs](topics/coroutines.md "Using Deferred-based APIs") about coroutine-based
  and Deferred-based APIs.
  ([#6800](https://github.com/scrapy/scrapy/issues/6800), [#7146](https://github.com/scrapy/scrapy/issues/7146))
- Other documentation improvements and fixes.
  ([#7058](https://github.com/scrapy/scrapy/issues/7058), [#7076](https://github.com/scrapy/scrapy/issues/7076), [#7109](https://github.com/scrapy/scrapy/issues/7109), [#7195](https://github.com/scrapy/scrapy/issues/7195), [#7198](https://github.com/scrapy/scrapy/issues/7198))

### Quality assurance

- Switched from `twisted.trial` to `pytest-twisted` and replaced
  remaining `unittest` and `twisted.trial` features with `pytest` ones.
  ([#6658](https://github.com/scrapy/scrapy/issues/6658), [#6873](https://github.com/scrapy/scrapy/issues/6873), [#6884](https://github.com/scrapy/scrapy/issues/6884), [#6938](https://github.com/scrapy/scrapy/issues/6938))
- Enabled fancy `pytest` asserts.
  ([#6888](https://github.com/scrapy/scrapy/issues/6888))
- Added [Sphinx Lint](https://github.com/sphinx-contrib/sphinx-lint) to the `pre-commit` configuration.
  ([#6920](https://github.com/scrapy/scrapy/issues/6920))
- CI and test improvements and fixes.
  ([#6649](https://github.com/scrapy/scrapy/issues/6649),
  [#6769](https://github.com/scrapy/scrapy/issues/6769),
  [#6821](https://github.com/scrapy/scrapy/issues/6821),
  [#6835](https://github.com/scrapy/scrapy/issues/6835),
  [#6836](https://github.com/scrapy/scrapy/issues/6836),
  [#6846](https://github.com/scrapy/scrapy/issues/6846),
  [#6883](https://github.com/scrapy/scrapy/issues/6883),
  [#6885](https://github.com/scrapy/scrapy/issues/6885),
  [#6889](https://github.com/scrapy/scrapy/issues/6889),
  [#6905](https://github.com/scrapy/scrapy/issues/6905),
  [#6928](https://github.com/scrapy/scrapy/issues/6928),
  [#6933](https://github.com/scrapy/scrapy/issues/6933),
  [#6941](https://github.com/scrapy/scrapy/issues/6941),
  [#6942](https://github.com/scrapy/scrapy/issues/6942),
  [#6945](https://github.com/scrapy/scrapy/issues/6945),
  [#6947](https://github.com/scrapy/scrapy/issues/6947),
  [#6960](https://github.com/scrapy/scrapy/issues/6960),
  [#6968](https://github.com/scrapy/scrapy/issues/6968),
  [#6972](https://github.com/scrapy/scrapy/issues/6972),
  [#6974](https://github.com/scrapy/scrapy/issues/6974),
  [#6996](https://github.com/scrapy/scrapy/issues/6996),
  [#7003](https://github.com/scrapy/scrapy/issues/7003),
  [#7012](https://github.com/scrapy/scrapy/issues/7012),
  [#7013](https://github.com/scrapy/scrapy/issues/7013),
  [#7050](https://github.com/scrapy/scrapy/issues/7050),
  [#7059](https://github.com/scrapy/scrapy/issues/7059),
  [#7070](https://github.com/scrapy/scrapy/issues/7070),
  [#7073](https://github.com/scrapy/scrapy/issues/7073),
  [#7118](https://github.com/scrapy/scrapy/issues/7118),
  [#7127](https://github.com/scrapy/scrapy/issues/7127),
  [#7141](https://github.com/scrapy/scrapy/issues/7141),
  [#7143](https://github.com/scrapy/scrapy/issues/7143),
  [#7145](https://github.com/scrapy/scrapy/issues/7145),
  [#7173](https://github.com/scrapy/scrapy/issues/7173))
- Code cleanups.
  ([#6803](https://github.com/scrapy/scrapy/issues/6803),
  [#6838](https://github.com/scrapy/scrapy/issues/6838),
  [#6849](https://github.com/scrapy/scrapy/issues/6849),
  [#6875](https://github.com/scrapy/scrapy/issues/6875),
  [#6876](https://github.com/scrapy/scrapy/issues/6876),
  [#6892](https://github.com/scrapy/scrapy/issues/6892),
  [#6930](https://github.com/scrapy/scrapy/issues/6930),
  [#6949](https://github.com/scrapy/scrapy/issues/6949),
  [#6970](https://github.com/scrapy/scrapy/issues/6970),
  [#6977](https://github.com/scrapy/scrapy/issues/6977),
  [#6986](https://github.com/scrapy/scrapy/issues/6986),
  [#7008](https://github.com/scrapy/scrapy/issues/7008),
  [#7177](https://github.com/scrapy/scrapy/issues/7177))

## Older releases

* [Older Scrapy 2.x release notes](news/2.x.md)
* [Scrapy 1.x release notes](news/1.x.md)
* [Scrapy 0.x release notes](news/0.x.md)
