.. _news:
Release notes
=============
.. note:: Scrapy 1.x is the last series supporting Python 2. Scrapy 2.x
supports **Python 3 only**.
.. _release-1.8.4:
Scrapy 1.8.4 (2024-02-14)
-------------------------
**Security bug fix:**
- Due to its `ReDoS vulnerabilities`_, ``scrapy.utils.iterators.xmliter`` is
now deprecated in favor of :func:`~scrapy.utils.iterators.xmliter_lxml`,
which :class:`~scrapy.spiders.XMLFeedSpider` now uses.
To minimize the impact of this change on existing code,
:func:`~scrapy.utils.iterators.xmliter_lxml` now supports indicating
the node namespace as a prefix in the node name, and big files with highly
nested trees when using libxml2 2.7+.
Please, see the `cc65-xxvf-f7r9 security advisory`_ for more information.
.. _ReDoS vulnerability: https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
.. _cc65-xxvf-f7r9 security advisory: https://github.com/scrapy/scrapy/security/advisories/GHSA-cc65-xxvf-f7r9
- :setting:`DOWNLOAD_MAXSIZE` and :setting:`DOWNLOAD_WARNSIZE` now also apply
to the decompressed response body. Please, see the `7j7m-v7m3-jqm7 security
advisory`_ for more information.
.. _7j7m-v7m3-jqm7 security advisory: https://github.com/scrapy/scrapy/security/advisories/GHSA-7j7m-v7m3-jqm7
- Also in relation with the `7j7m-v7m3-jqm7 security advisory`_, use of the
``scrapy.downloadermiddlewares.decompression`` module is discouraged and
will trigger a warning.
- The ``Authorization`` header is now dropped on redirects to a different
domain. Please, see the `cw9j-q3vf-hrrv security advisory`_ for more
information.
.. _cw9j-q3vf-hrrv security advisory: https://github.com/scrapy/scrapy/security/advisories/GHSA-cw9j-q3vf-hrrv
.. _release-1.8.3:
Scrapy 1.8.3 (2022-07-25)
-------------------------
**Security bug fix:**
- When :class:`~scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware`
processes a request with :reqmeta:`proxy` metadata, and that
:reqmeta:`proxy` metadata includes proxy credentials,
:class:`~scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware` sets
the ``Proxy-Authentication`` header, but only if that header is not already
set.
There are third-party proxy-rotation downloader middlewares that set
different :reqmeta:`proxy` metadata every time they process a request.
Because of request retries and redirects, the same request can be processed
by downloader middlewares more than once, including both
:class:`~scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware` and
any third-party proxy-rotation downloader middleware.
These third-party proxy-rotation downloader middlewares could change the
:reqmeta:`proxy` metadata of a request to a new value, but fail to remove
the ``Proxy-Authentication`` header from the previous value of the
:reqmeta:`proxy` metadata, causing the credentials of one proxy to be sent
to a different proxy.
To prevent the unintended leaking of proxy credentials, the behavior of
:class:`~scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware` is now
as follows when processing a request:
- If the request being processed defines :reqmeta:`proxy` metadata that
includes credentials, the ``Proxy-Authorization`` header is always
updated to feature those credentials.
- If the request being processed defines :reqmeta:`proxy` metadata
without credentials, the ``Proxy-Authorization`` header is removed
*unless* it was originally defined for the same proxy URL.
To remove proxy credentials while keeping the same proxy URL, remove
the ``Proxy-Authorization`` header.
- If the request has no :reqmeta:`proxy` metadata, or that metadata is a
falsy value (e.g. ``None``), the ``Proxy-Authorization`` header is
removed.
It is no longer possible to set a proxy URL through the
:reqmeta:`proxy` metadata but set the credentials through the
``Proxy-Authorization`` header. Set proxy credentials through the
:reqmeta:`proxy` metadata instead.
.. _release-1.8.2:
Scrapy 1.8.2 (2022-03-01)
-------------------------
**Security bug fixes:**
- When a :class:`~scrapy.http.Request` object with cookies defined gets a
redirect response causing a new :class:`~scrapy.http.Request` object to be
scheduled, the cookies defined in the original
:class:`~scrapy.http.Request` object are no longer copied into the new
:class:`~scrapy.http.Request` object.
If you manually set the ``Cookie`` header on a
:class:`~scrapy.http.Request` object and the domain name of the redirect
URL is not an exact match for the domain of the URL of the original
:class:`~scrapy.http.Request` object, your ``Cookie`` header is now dropped
from the new :class:`~scrapy.http.Request` object.
The old behavior could be exploited by an attacker to gain access to your
cookies. Please, see the `cjvr-mfj7-j4j8 security advisory`_ for more
information.
.. _cjvr-mfj7-j4j8 security advisory: https://github.com/scrapy/scrapy/security/advisories/GHSA-cjvr-mfj7-j4j8
.. note:: It is still possible to enable the sharing of cookies between
different domains with a shared domain suffix (e.g.
``example.com`` and any subdomain) by defining the shared domain
suffix (e.g. ``example.com``) as the cookie domain when defining
your cookies. See the documentation of the
:class:`~scrapy.http.Request` class for more information.
- When the domain of a cookie, either received in the ``Set-Cookie`` header
of a response or defined in a :class:`~scrapy.http.Request` object, is set
to a `public suffix `_, the cookie is now
ignored unless the cookie domain is the same as the request domain.
The old behavior could be exploited by an attacker to inject cookies into
your requests to some other domains. Please, see the `mfjm-vh54-3f96
security advisory`_ for more information.
.. _mfjm-vh54-3f96 security advisory: https://github.com/scrapy/scrapy/security/advisories/GHSA-mfjm-vh54-3f96
.. _release-1.8.1:
Scrapy 1.8.1 (2021-10-05)
-------------------------
* **Security bug fix:**
If you use
:class:`~scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware`
(i.e. the ``http_user`` and ``http_pass`` spider attributes) for HTTP
authentication, any request exposes your credentials to the request target.
To prevent unintended exposure of authentication credentials to unintended
domains, you must now additionally set a new, additional spider attribute,
``http_auth_domain``, and point it to the specific domain to which the
authentication credentials must be sent.
If the ``http_auth_domain`` spider attribute is not set, the domain of the
first request will be considered the HTTP authentication target, and
authentication credentials will only be sent in requests targeting that
domain.
If you need to send the same HTTP authentication credentials to multiple
domains, you can use :func:`w3lib.http.basic_auth_header` instead to
set the value of the ``Authorization`` header of your requests.
If you *really* want your spider to send the same HTTP authentication
credentials to any domain, set the ``http_auth_domain`` spider attribute
to ``None``.
Finally, if you are a user of `scrapy-splash`_, know that this version of
Scrapy breaks compatibility with scrapy-splash 0.7.2 and earlier. You will
need to upgrade scrapy-splash to a greater version for it to continue to
work.
.. _scrapy-splash: https://github.com/scrapy-plugins/scrapy-splash
.. _release-1.8.0:
Scrapy 1.8.0 (2019-10-28)
-------------------------
Highlights:
* Dropped Python 3.4 support and updated minimum requirements; made Python 3.8
support official
* New :meth:`Request.from_curl ` class method
* New :setting:`ROBOTSTXT_PARSER` and :setting:`ROBOTSTXT_USER_AGENT` settings
* New :setting:`DOWNLOADER_CLIENT_TLS_CIPHERS` and
:setting:`DOWNLOADER_CLIENT_TLS_VERBOSE_LOGGING` settings
Backward-incompatible changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Python 3.4 is no longer supported, and some of the minimum requirements of
Scrapy have also changed:
* cssselect_ 0.9.1
* cryptography_ 2.0
* lxml_ 3.5.0
* pyOpenSSL_ 16.2.0
* queuelib_ 1.4.2
* service_identity_ 16.0.0
* six_ 1.10.0
* Twisted_ 17.9.0 (16.0.0 with Python 2)
* zope.interface_ 4.1.3
(:issue:`3892`)
* ``JSONRequest`` is now called :class:`~scrapy.http.JsonRequest` for
consistency with similar classes (:issue:`3929`, :issue:`3982`)
* If you are using a custom context factory
(:setting:`DOWNLOADER_CLIENTCONTEXTFACTORY`), its ``__init__`` method must
accept two new parameters: ``tls_verbose_logging`` and ``tls_ciphers``
(:issue:`2111`, :issue:`3392`, :issue:`3442`, :issue:`3450`)
* :class:`~scrapy.loader.ItemLoader` now turns the values of its input item
into lists::
>>> item = MyItem()
>>> item['field'] = 'value1'
>>> loader = ItemLoader(item=item)
>>> item['field']
['value1']
This is needed to allow adding values to existing fields
(``loader.add_value('field', 'value2')``).
(:issue:`3804`, :issue:`3819`, :issue:`3897`, :issue:`3976`, :issue:`3998`,
:issue:`4036`)
See also :ref:`1.8-deprecation-removals` below.
New features
~~~~~~~~~~~~
* A new :meth:`Request.from_curl ` class
method allows :ref:`creating a request from a cURL command
` (:issue:`2985`, :issue:`3862`)
* A new :setting:`ROBOTSTXT_PARSER` setting allows choosing which robots.txt_
parser to use. It includes built-in support for
:ref:`RobotFileParser `,
:ref:`Protego ` (default), :ref:`Reppy `, and
:ref:`Robotexclusionrulesparser `, and allows you to
:ref:`implement support for additional parsers
` (:issue:`754`, :issue:`2669`,
:issue:`3796`, :issue:`3935`, :issue:`3969`, :issue:`4006`)
* A new :setting:`ROBOTSTXT_USER_AGENT` setting allows defining a separate
user agent string to use for robots.txt_ parsing (:issue:`3931`,
:issue:`3966`)
* :class:`~scrapy.spiders.Rule` no longer requires a :class:`LinkExtractor
` parameter
(:issue:`781`, :issue:`4016`)
* Use the new :setting:`DOWNLOADER_CLIENT_TLS_CIPHERS` setting to customize
the TLS/SSL ciphers used by the default HTTP/1.1 downloader (:issue:`3392`,
:issue:`3442`)
* Set the new :setting:`DOWNLOADER_CLIENT_TLS_VERBOSE_LOGGING` setting to
``True`` to enable debug-level messages about TLS connection parameters
after establishing HTTPS connections (:issue:`2111`, :issue:`3450`)
* Callbacks that receive keyword arguments
(see :attr:`Request.cb_kwargs `) can now be
tested using the new :class:`@cb_kwargs
`
:ref:`spider contract ` (:issue:`3985`, :issue:`3988`)
* When a :class:`@scrapes ` spider
contract fails, all missing fields are now reported (:issue:`766`,
:issue:`3939`)
* :ref:`Custom log formats ` can now drop messages by
having the corresponding methods of the configured :setting:`LOG_FORMATTER`
return ``None`` (:issue:`3984`, :issue:`3987`)
* A much improved completion definition is now available for Zsh_
(:issue:`4069`)
Bug fixes
~~~~~~~~~
* :meth:`ItemLoader.load_item() ` no
longer makes later calls to :meth:`ItemLoader.get_output_value()
` or
:meth:`ItemLoader.load_item() ` return
empty data (:issue:`3804`, :issue:`3819`, :issue:`3897`, :issue:`3976`,
:issue:`3998`, :issue:`4036`)
* Fixed :class:`~scrapy.statscollectors.DummyStatsCollector` raising a
:exc:`TypeError` exception (:issue:`4007`, :issue:`4052`)
* :meth:`FilesPipeline.file_path
` and
:meth:`ImagesPipeline.file_path
` no longer choose
file extensions that are not `registered with IANA`_ (:issue:`1287`,
:issue:`3953`, :issue:`3954`)
* When using botocore_ to persist files in S3, all botocore-supported headers
are properly mapped now (:issue:`3904`, :issue:`3905`)
* FTP passwords in :setting:`FEED_URI` containing percent-escaped characters
are now properly decoded (:issue:`3941`)
* A memory-handling and error-handling issue in
:func:`scrapy.utils.ssl.get_temp_key_info` has been fixed (:issue:`3920`)
Documentation
~~~~~~~~~~~~~
* The documentation now covers how to define and configure a :ref:`custom log
format ` (:issue:`3616`, :issue:`3660`)
* API documentation added for :class:`~scrapy.exporters.MarshalItemExporter`
and :class:`~scrapy.exporters.PythonItemExporter` (:issue:`3973`)
* API documentation added for :class:`~scrapy.item.BaseItem` and
:class:`~scrapy.item.ItemMeta` (:issue:`3999`)
* Minor documentation fixes (:issue:`2998`, :issue:`3398`, :issue:`3597`,
:issue:`3894`, :issue:`3934`, :issue:`3978`, :issue:`3993`, :issue:`4022`,
:issue:`4028`, :issue:`4033`, :issue:`4046`, :issue:`4050`, :issue:`4055`,
:issue:`4056`, :issue:`4061`, :issue:`4072`, :issue:`4071`, :issue:`4079`,
:issue:`4081`, :issue:`4089`, :issue:`4093`)
.. _1.8-deprecation-removals:
Deprecation removals
~~~~~~~~~~~~~~~~~~~~
* ``scrapy.xlib`` has been removed (:issue:`4015`)
Deprecations
~~~~~~~~~~~~
* The LevelDB_ storage backend
(``scrapy.extensions.httpcache.LeveldbCacheStorage``) of
:class:`~scrapy.downloadermiddlewares.httpcache.HttpCacheMiddleware` is
deprecated (:issue:`4085`, :issue:`4092`)
* Use of the undocumented ``SCRAPY_PICKLED_SETTINGS_TO_OVERRIDE`` environment
variable is deprecated (:issue:`3910`)
* ``scrapy.item.DictItem`` is deprecated, use :class:`~scrapy.item.Item`
instead (:issue:`3999`)
Other changes
~~~~~~~~~~~~~
* Minimum versions of optional Scrapy requirements that are covered by
continuous integration tests have been updated:
* botocore_ 1.3.23
* Pillow_ 3.4.2
Lower versions of these optional requirements may work, but it is not
guaranteed (:issue:`3892`)
* GitHub templates for bug reports and feature requests (:issue:`3126`,
:issue:`3471`, :issue:`3749`, :issue:`3754`)
* Continuous integration fixes (:issue:`3923`)
* Code cleanup (:issue:`3391`, :issue:`3907`, :issue:`3946`, :issue:`3950`,
:issue:`4023`, :issue:`4031`)
.. _release-1.7.4:
Scrapy 1.7.4 (2019-10-21)
-------------------------
Revert the fix for :issue:`3804` (:issue:`3819`), which has a few undesired
side effects (:issue:`3897`, :issue:`3976`).
As a result, when an item loader is initialized with an item,
:meth:`ItemLoader.load_item() ` once again
makes later calls to :meth:`ItemLoader.get_output_value()
` or :meth:`ItemLoader.load_item()
` return empty data.
.. _release-1.7.3:
Scrapy 1.7.3 (2019-08-01)
-------------------------
Enforce lxml 4.3.5 or lower for Python 3.4 (:issue:`3912`, :issue:`3918`).
.. _release-1.7.2:
Scrapy 1.7.2 (2019-07-23)
-------------------------
Fix Python 2 support (:issue:`3889`, :issue:`3893`, :issue:`3896`).
.. _release-1.7.1:
Scrapy 1.7.1 (2019-07-18)
-------------------------
Re-packaging of Scrapy 1.7.0, which was missing some changes in PyPI.
.. _release-1.7.0:
Scrapy 1.7.0 (2019-07-18)
-------------------------
.. note:: Make sure you install Scrapy 1.7.1. The Scrapy 1.7.0 package in PyPI
is the result of an erroneous commit tagging and does not include all
the changes described below.
Highlights:
* Improvements for crawls targeting multiple domains
* A cleaner way to pass arguments to callbacks
* A new class for JSON requests
* Improvements for rule-based spiders
* New features for feed exports
Backward-incompatible changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* ``429`` is now part of the :setting:`RETRY_HTTP_CODES` setting by default
This change is **backward incompatible**. If you don’t want to retry
``429``, you must override :setting:`RETRY_HTTP_CODES` accordingly.
* :class:`~scrapy.crawler.Crawler`,
:class:`CrawlerRunner.crawl ` and
:class:`CrawlerRunner.create_crawler `
no longer accept a :class:`~scrapy.spiders.Spider` subclass instance, they
only accept a :class:`~scrapy.spiders.Spider` subclass now.
:class:`~scrapy.spiders.Spider` subclass instances were never meant to
work, and they were not working as one would expect: instead of using the
passed :class:`~scrapy.spiders.Spider` subclass instance, their
:class:`~scrapy.spiders.Spider.from_crawler` method was called to generate
a new instance.
* Non-default values for the :setting:`SCHEDULER_PRIORITY_QUEUE` setting
may stop working. Scheduler priority queue classes now need to handle
:class:`~scrapy.http.Request` objects instead of arbitrary Python data
structures.
See also :ref:`1.7-deprecation-removals` below.
New features
~~~~~~~~~~~~
* A new scheduler priority queue,
``scrapy.pqueues.DownloaderAwarePriorityQueue``, may be
:ref:`enabled ` for a significant
scheduling improvement on crawls targetting multiple web domains, at the
cost of no :setting:`CONCURRENT_REQUESTS_PER_IP` support (:issue:`3520`)
* A new :attr:`Request.cb_kwargs ` attribute
provides a cleaner way to pass keyword arguments to callback methods
(:issue:`1138`, :issue:`3563`)
* A new :class:`JSONRequest ` class offers a more
convenient way to build JSON requests (:issue:`3504`, :issue:`3505`)
* A ``process_request`` callback passed to the :class:`~scrapy.spiders.Rule`
constructor now receives the :class:`~scrapy.http.Response` object that
originated the request as its second argument (:issue:`3682`)
* A new ``restrict_text`` parameter for the
:attr:`LinkExtractor `
constructor allows filtering links by linking text (:issue:`3622`,
:issue:`3635`)
* A new :setting:`FEED_STORAGE_S3_ACL` setting allows defining a custom ACL
for feeds exported to Amazon S3 (:issue:`3607`)
* A new :setting:`FEED_STORAGE_FTP_ACTIVE` setting allows using FTP’s active
connection mode for feeds exported to FTP servers (:issue:`3829`)
* A new :setting:`METAREFRESH_IGNORE_TAGS` setting allows overriding which
HTML tags are ignored when searching a response for HTML meta tags that
trigger a redirect (:issue:`1422`, :issue:`3768`)
* A new :reqmeta:`redirect_reasons` request meta key exposes the reason
(status code, meta refresh) behind every followed redirect (:issue:`3581`,
:issue:`3687`)
* The ``SCRAPY_CHECK`` variable is now set to the ``true`` string during runs
of the :command:`check` command, which allows :ref:`detecting contract
check runs from code ` (:issue:`3704`,
:issue:`3739`)
* A new :meth:`Item.deepcopy() ` method makes it
easier to :ref:`deep-copy items ` (:issue:`1493`,
:issue:`3671`)
* :class:`~scrapy.extensions.corestats.CoreStats` also logs
``elapsed_time_seconds`` now (:issue:`3638`)
* Exceptions from :class:`~scrapy.loader.ItemLoader` :ref:`input and output
processors ` are now more verbose
(:issue:`3836`, :issue:`3840`)
* :class:`~scrapy.crawler.Crawler`,
:class:`CrawlerRunner.crawl ` and
:class:`CrawlerRunner.create_crawler `
now fail gracefully if they receive a :class:`~scrapy.spiders.Spider`
subclass instance instead of the subclass itself (:issue:`2283`,
:issue:`3610`, :issue:`3872`)
Bug fixes
~~~~~~~~~
* :meth:`~scrapy.spidermiddlewares.SpiderMiddleware.process_spider_exception`
is now also invoked for generators (:issue:`220`, :issue:`2061`)
* System exceptions like KeyboardInterrupt_ are no longer caught
(:issue:`3726`)
* :meth:`ItemLoader.load_item() ` no
longer makes later calls to :meth:`ItemLoader.get_output_value()
` or
:meth:`ItemLoader.load_item() ` return
empty data (:issue:`3804`, :issue:`3819`)
* The images pipeline (:class:`~scrapy.pipelines.images.ImagesPipeline`) no
longer ignores these Amazon S3 settings: :setting:`AWS_ENDPOINT_URL`,
:setting:`AWS_REGION_NAME`, :setting:`AWS_USE_SSL`, :setting:`AWS_VERIFY`
(:issue:`3625`)
* Fixed a memory leak in ``scrapy.pipelines.media.MediaPipeline`` affecting,
for example, non-200 responses and exceptions from custom middlewares
(:issue:`3813`)
* Requests with private callbacks are now correctly unserialized from disk
(:issue:`3790`)
* :meth:`FormRequest.from_response() `
now handles invalid methods like major web browsers (:issue:`3777`,
:issue:`3794`)
Documentation
~~~~~~~~~~~~~
* A new topic, :ref:`topics-dynamic-content`, covers recommended approaches
to read dynamically-loaded data (:issue:`3703`)
* :ref:`topics-broad-crawls` now features information about memory usage
(:issue:`1264`, :issue:`3866`)
* The documentation of :class:`~scrapy.spiders.Rule` now covers how to access
the text of a link when using :class:`~scrapy.spiders.CrawlSpider`
(:issue:`3711`, :issue:`3712`)
* A new section, :ref:`httpcache-storage-custom`, covers writing a custom
cache storage backend for
:class:`~scrapy.downloadermiddlewares.httpcache.HttpCacheMiddleware`
(:issue:`3683`, :issue:`3692`)
* A new :ref:`FAQ ` entry, :ref:`faq-split-item`, explains what to do
when you want to split an item into multiple items from an item pipeline
(:issue:`2240`, :issue:`3672`)
* Updated the :ref:`FAQ entry about crawl order ` to explain why
the first few requests rarely follow the desired order (:issue:`1739`,
:issue:`3621`)
* The :setting:`LOGSTATS_INTERVAL` setting (:issue:`3730`), the
:meth:`FilesPipeline.file_path `
and
:meth:`ImagesPipeline.file_path `
methods (:issue:`2253`, :issue:`3609`) and the
:meth:`Crawler.stop() ` method (:issue:`3842`)
are now documented
* Some parts of the documentation that were confusing or misleading are now
clearer (:issue:`1347`, :issue:`1789`, :issue:`2289`, :issue:`3069`,
:issue:`3615`, :issue:`3626`, :issue:`3668`, :issue:`3670`, :issue:`3673`,
:issue:`3728`, :issue:`3762`, :issue:`3861`, :issue:`3882`)
* Minor documentation fixes (:issue:`3648`, :issue:`3649`, :issue:`3662`,
:issue:`3674`, :issue:`3676`, :issue:`3694`, :issue:`3724`, :issue:`3764`,
:issue:`3767`, :issue:`3791`, :issue:`3797`, :issue:`3806`, :issue:`3812`)
.. _1.7-deprecation-removals:
Deprecation removals
~~~~~~~~~~~~~~~~~~~~
The following deprecated APIs have been removed (:issue:`3578`):
* ``scrapy.conf`` (use :attr:`Crawler.settings
`)
* From ``scrapy.core.downloader.handlers``:
* ``http.HttpDownloadHandler`` (use ``http10.HTTP10DownloadHandler``)
* ``scrapy.loader.ItemLoader._get_values`` (use ``_get_xpathvalues``)
* ``scrapy.loader.XPathItemLoader`` (use :class:`~scrapy.loader.ItemLoader`)
* ``scrapy.log`` (see :ref:`topics-logging`)
* From ``scrapy.pipelines``:
* ``files.FilesPipeline.file_key`` (use ``file_path``)
* ``images.ImagesPipeline.file_key`` (use ``file_path``)
* ``images.ImagesPipeline.image_key`` (use ``file_path``)
* ``images.ImagesPipeline.thumb_key`` (use ``thumb_path``)
* From both ``scrapy.selector`` and ``scrapy.selector.lxmlsel``:
* ``HtmlXPathSelector`` (use :class:`~scrapy.selector.Selector`)
* ``XmlXPathSelector`` (use :class:`~scrapy.selector.Selector`)
* ``XPathSelector`` (use :class:`~scrapy.selector.Selector`)
* ``XPathSelectorList`` (use :class:`~scrapy.selector.Selector`)
* From ``scrapy.selector.csstranslator``:
* ``ScrapyGenericTranslator`` (use parsel.csstranslator.GenericTranslator_)
* ``ScrapyHTMLTranslator`` (use parsel.csstranslator.HTMLTranslator_)
* ``ScrapyXPathExpr`` (use parsel.csstranslator.XPathExpr_)
* From :class:`~scrapy.selector.Selector`:
* ``_root`` (both the constructor argument and the object property, use
``root``)
* ``extract_unquoted`` (use ``getall``)
* ``select`` (use ``xpath``)
* From :class:`~scrapy.selector.SelectorList`:
* ``extract_unquoted`` (use ``getall``)
* ``select`` (use ``xpath``)
* ``x`` (use ``xpath``)
* ``scrapy.spiders.BaseSpider`` (use :class:`~scrapy.spiders.Spider`)
* From :class:`~scrapy.spiders.Spider` (and subclasses):
* ``DOWNLOAD_DELAY`` (use :ref:`download_delay
`)
* ``set_crawler`` (use :meth:`~scrapy.spiders.Spider.from_crawler`)
* ``scrapy.spiders.spiders`` (use :class:`~scrapy.spiderloader.SpiderLoader`)
* ``scrapy.telnet`` (use :mod:`scrapy.extensions.telnet`)
* From ``scrapy.utils.python``:
* ``str_to_unicode`` (use ``to_unicode``)
* ``unicode_to_str`` (use ``to_bytes``)
* ``scrapy.utils.response.body_or_str``
The following deprecated settings have also been removed (:issue:`3578`):
* ``SPIDER_MANAGER_CLASS`` (use :setting:`SPIDER_LOADER_CLASS`)
Deprecations
~~~~~~~~~~~~
* The ``queuelib.PriorityQueue`` value for the
:setting:`SCHEDULER_PRIORITY_QUEUE` setting is deprecated. Use
``scrapy.pqueues.ScrapyPriorityQueue`` instead.
* ``process_request`` callbacks passed to :class:`~scrapy.spiders.Rule` that
do not accept two arguments are deprecated.
* The following modules are deprecated:
* ``scrapy.utils.http`` (use `w3lib.http`_)
* ``scrapy.utils.markup`` (use `w3lib.html`_)
* ``scrapy.utils.multipart`` (use `urllib3`_)
* The ``scrapy.utils.datatypes.MergeDict`` class is deprecated for Python 3
code bases. Use :class:`~collections.ChainMap` instead. (:issue:`3878`)
* The ``scrapy.utils.gz.is_gzipped`` function is deprecated. Use
``scrapy.utils.gz.gzip_magic_number`` instead.
.. _urllib3: https://urllib3.readthedocs.io/en/latest/index.html
.. _w3lib.html: https://w3lib.readthedocs.io/en/latest/w3lib.html#module-w3lib.html
.. _w3lib.http: https://w3lib.readthedocs.io/en/latest/w3lib.html#module-w3lib.http
Other changes
~~~~~~~~~~~~~
* It is now possible to run all tests from the same tox_ environment in
parallel; the documentation now covers :ref:`this and other ways to run
tests ` (:issue:`3707`)
* It is now possible to generate an API documentation coverage report
(:issue:`3806`, :issue:`3810`, :issue:`3860`)
* The :ref:`documentation policies ` now require
docstrings_ (:issue:`3701`) that follow `PEP 257`_ (:issue:`3748`)
* Internal fixes and cleanup (:issue:`3629`, :issue:`3643`, :issue:`3684`,
:issue:`3698`, :issue:`3734`, :issue:`3735`, :issue:`3736`, :issue:`3737`,
:issue:`3809`, :issue:`3821`, :issue:`3825`, :issue:`3827`, :issue:`3833`,
:issue:`3857`, :issue:`3877`)
.. _release-1.6.0:
Scrapy 1.6.0 (2019-01-30)
-------------------------
Highlights:
* better Windows support;
* Python 3.7 compatibility;
* big documentation improvements, including a switch
from ``.extract_first()`` + ``.extract()`` API to ``.get()`` + ``.getall()``
API;
* feed exports, FilePipeline and MediaPipeline improvements;
* better extensibility: :signal:`item_error` and
:signal:`request_reached_downloader` signals; ``from_crawler`` support
for feed exporters, feed storages and dupefilters.
* ``scrapy.contracts`` fixes and new features;
* telnet console security improvements, first released as a
backport in :ref:`release-1.5.2`;
* clean-up of the deprecated code;
* various bug fixes, small new features and usability improvements across
the codebase.
Selector API changes
~~~~~~~~~~~~~~~~~~~~
While these are not changes in Scrapy itself, but rather in the parsel_
library which Scrapy uses for xpath/css selectors, these changes are
worth mentioning here. Scrapy now depends on parsel >= 1.5, and
Scrapy documentation is updated to follow recent ``parsel`` API conventions.
Most visible change is that ``.get()`` and ``.getall()`` selector
methods are now preferred over ``.extract_first()`` and ``.extract()``.
We feel that these new methods result in a more concise and readable code.
See :ref:`old-extraction-api` for more details.
.. note::
There are currently **no plans** to deprecate ``.extract()``
and ``.extract_first()`` methods.
Another useful new feature is the introduction of ``Selector.attrib`` and
``SelectorList.attrib`` properties, which make it easier to get
attributes of HTML elements. See :ref:`selecting-attributes`.
CSS selectors are cached in parsel >= 1.5, which makes them faster
when the same CSS path is used many times. This is very common in
case of Scrapy spiders: callbacks are usually called several times,
on different pages.
If you're using custom ``Selector`` or ``SelectorList`` subclasses,
a **backward incompatible** change in parsel may affect your code.
See `parsel changelog`_ for a detailed description, as well as for the
full list of improvements.
.. _parsel changelog: https://parsel.readthedocs.io/en/latest/history.html
Telnet console
~~~~~~~~~~~~~~
**Backward incompatible**: Scrapy's telnet console now requires username
and password. See :ref:`topics-telnetconsole` for more details. This change
fixes a **security issue**; see :ref:`release-1.5.2` release notes for details.
New extensibility features
~~~~~~~~~~~~~~~~~~~~~~~~~~
* ``from_crawler`` support is added to feed exporters and feed storages. This,
among other things, allows to access Scrapy settings from custom feed
storages and exporters (:issue:`1605`, :issue:`3348`).
* ``from_crawler`` support is added to dupefilters (:issue:`2956`); this allows
to access e.g. settings or a spider from a dupefilter.
* :signal:`item_error` is fired when an error happens in a pipeline
(:issue:`3256`);
* :signal:`request_reached_downloader` is fired when Downloader gets
a new Request; this signal can be useful e.g. for custom Schedulers
(:issue:`3393`).
* new SitemapSpider :meth:`~.SitemapSpider.sitemap_filter` method which allows
to select sitemap entries based on their attributes in SitemapSpider
subclasses (:issue:`3512`).
* Lazy loading of Downloader Handlers is now optional; this enables better
initialization error handling in custom Downloader Handlers (:issue:`3394`).
New FilePipeline and MediaPipeline features
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Expose more options for S3FilesStore: :setting:`AWS_ENDPOINT_URL`,
:setting:`AWS_USE_SSL`, :setting:`AWS_VERIFY`, :setting:`AWS_REGION_NAME`.
For example, this allows to use alternative or self-hosted
AWS-compatible providers (:issue:`2609`, :issue:`3548`).
* ACL support for Google Cloud Storage: :setting:`FILES_STORE_GCS_ACL` and
:setting:`IMAGES_STORE_GCS_ACL` (:issue:`3199`).
``scrapy.contracts`` improvements
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Exceptions in contracts code are handled better (:issue:`3377`);
* ``dont_filter=True`` is used for contract requests, which allows to test
different callbacks with the same URL (:issue:`3381`);
* ``request_cls`` attribute in Contract subclasses allow to use different
Request classes in contracts, for example FormRequest (:issue:`3383`).
* Fixed errback handling in contracts, e.g. for cases where a contract
is executed for URL which returns non-200 response (:issue:`3371`).
Usability improvements
~~~~~~~~~~~~~~~~~~~~~~
* more stats for RobotsTxtMiddleware (:issue:`3100`)
* INFO log level is used to show telnet host/port (:issue:`3115`)
* a message is added to IgnoreRequest in RobotsTxtMiddleware (:issue:`3113`)
* better validation of ``url`` argument in ``Response.follow`` (:issue:`3131`)
* non-zero exit code is returned from Scrapy commands when error happens
on spider inititalization (:issue:`3226`)
* Link extraction improvements: "ftp" is added to scheme list (:issue:`3152`);
"flv" is added to common video extensions (:issue:`3165`)
* better error message when an exporter is disabled (:issue:`3358`);
* ``scrapy shell --help`` mentions syntax required for local files
(``./file.html``) - :issue:`3496`.
* Referer header value is added to RFPDupeFilter log messages (:issue:`3588`)
Bug fixes
~~~~~~~~~
* fixed issue with extra blank lines in .csv exports under Windows
(:issue:`3039`);
* proper handling of pickling errors in Python 3 when serializing objects
for disk queues (:issue:`3082`)
* flags are now preserved when copying Requests (:issue:`3342`);
* FormRequest.from_response clickdata shouldn't ignore elements with
``input[type=image]`` (:issue:`3153`).
* FormRequest.from_response should preserve duplicate keys (:issue:`3247`)
Documentation improvements
~~~~~~~~~~~~~~~~~~~~~~~~~~
* Docs are re-written to suggest .get/.getall API instead of
.extract/.extract_first. Also, :ref:`topics-selectors` docs are updated
and re-structured to match latest parsel docs; they now contain more topics,
such as :ref:`selecting-attributes` or :ref:`topics-selectors-css-extensions`
(:issue:`3390`).
* :ref:`topics-developer-tools` is a new tutorial which replaces
old Firefox and Firebug tutorials (:issue:`3400`).
* SCRAPY_PROJECT environment variable is documented (:issue:`3518`);
* troubleshooting section is added to install instructions (:issue:`3517`);
* improved links to beginner resources in the tutorial
(:issue:`3367`, :issue:`3468`);
* fixed :setting:`RETRY_HTTP_CODES` default values in docs (:issue:`3335`);
* remove unused ``DEPTH_STATS`` option from docs (:issue:`3245`);
* other cleanups (:issue:`3347`, :issue:`3350`, :issue:`3445`, :issue:`3544`,
:issue:`3605`).
Deprecation removals
~~~~~~~~~~~~~~~~~~~~
Compatibility shims for pre-1.0 Scrapy module names are removed
(:issue:`3318`):
* ``scrapy.command``
* ``scrapy.contrib`` (with all submodules)
* ``scrapy.contrib_exp`` (with all submodules)
* ``scrapy.dupefilter``
* ``scrapy.linkextractor``
* ``scrapy.project``
* ``scrapy.spider``
* ``scrapy.spidermanager``
* ``scrapy.squeue``
* ``scrapy.stats``
* ``scrapy.statscol``
* ``scrapy.utils.decorator``
See :ref:`module-relocations` for more information, or use suggestions
from Scrapy 1.5.x deprecation warnings to update your code.
Other deprecation removals:
* Deprecated scrapy.interfaces.ISpiderManager is removed; please use
scrapy.interfaces.ISpiderLoader.
* Deprecated ``CrawlerSettings`` class is removed (:issue:`3327`).
* Deprecated ``Settings.overrides`` and ``Settings.defaults`` attributes
are removed (:issue:`3327`, :issue:`3359`).
Other improvements, cleanups
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* All Scrapy tests now pass on Windows; Scrapy testing suite is executed
in a Windows environment on CI (:issue:`3315`).
* Python 3.7 support (:issue:`3326`, :issue:`3150`, :issue:`3547`).
* Testing and CI fixes (:issue:`3526`, :issue:`3538`, :issue:`3308`,
:issue:`3311`, :issue:`3309`, :issue:`3305`, :issue:`3210`, :issue:`3299`)
* ``scrapy.http.cookies.CookieJar.clear`` accepts "domain", "path" and "name"
optional arguments (:issue:`3231`).
* additional files are included to sdist (:issue:`3495`);
* code style fixes (:issue:`3405`, :issue:`3304`);
* unneeded .strip() call is removed (:issue:`3519`);
* collections.deque is used to store MiddlewareManager methods instead
of a list (:issue:`3476`)
.. _release-1.5.2:
Scrapy 1.5.2 (2019-01-22)
-------------------------
* *Security bugfix*: Telnet console extension can be easily exploited by rogue
websites POSTing content to http://localhost:6023, we haven't found a way to
exploit it from Scrapy, but it is very easy to trick a browser to do so and
elevates the risk for local development environment.
*The fix is backward incompatible*, it enables telnet user-password
authentication by default with a random generated password. If you can't
upgrade right away, please consider setting :setting:`TELNETCONSOLE_PORT`
out of its default value.
See :ref:`telnet console ` documentation for more info
* Backport CI build failure under GCE environment due to boto import error.
.. _release-1.5.1:
Scrapy 1.5.1 (2018-07-12)
-------------------------
This is a maintenance release with important bug fixes, but no new features:
* ``O(N^2)`` gzip decompression issue which affected Python 3 and PyPy
is fixed (:issue:`3281`);
* skipping of TLS validation errors is improved (:issue:`3166`);
* Ctrl-C handling is fixed in Python 3.5+ (:issue:`3096`);
* testing fixes (:issue:`3092`, :issue:`3263`);
* documentation improvements (:issue:`3058`, :issue:`3059`, :issue:`3089`,
:issue:`3123`, :issue:`3127`, :issue:`3189`, :issue:`3224`, :issue:`3280`,
:issue:`3279`, :issue:`3201`, :issue:`3260`, :issue:`3284`, :issue:`3298`,
:issue:`3294`).
.. _release-1.5.0:
Scrapy 1.5.0 (2017-12-29)
-------------------------
This release brings small new features and improvements across the codebase.
Some highlights:
* Google Cloud Storage is supported in FilesPipeline and ImagesPipeline.
* Crawling with proxy servers becomes more efficient, as connections
to proxies can be reused now.
* Warnings, exception and logging messages are improved to make debugging
easier.
* ``scrapy parse`` command now allows to set custom request meta via
``--meta`` argument.
* Compatibility with Python 3.6, PyPy and PyPy3 is improved;
PyPy and PyPy3 are now supported officially, by running tests on CI.
* Better default handling of HTTP 308, 522 and 524 status codes.
* Documentation is improved, as usual.
Backward Incompatible Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Scrapy 1.5 drops support for Python 3.3.
* Default Scrapy User-Agent now uses https link to scrapy.org (:issue:`2983`).
**This is technically backward-incompatible**; override
:setting:`USER_AGENT` if you relied on old value.
* Logging of settings overridden by ``custom_settings`` is fixed;
**this is technically backward-incompatible** because the logger
changes from ``[scrapy.utils.log]`` to ``[scrapy.crawler]``. If you're
parsing Scrapy logs, please update your log parsers (:issue:`1343`).
* LinkExtractor now ignores ``m4v`` extension by default, this is change
in behavior.
* 522 and 524 status codes are added to ``RETRY_HTTP_CODES`` (:issue:`2851`)
New features
~~~~~~~~~~~~
- Support ```` tags in ``Response.follow`` (:issue:`2785`)
- Support for ``ptpython`` REPL (:issue:`2654`)
- Google Cloud Storage support for FilesPipeline and ImagesPipeline
(:issue:`2923`).
- New ``--meta`` option of the "scrapy parse" command allows to pass additional
request.meta (:issue:`2883`)
- Populate spider variable when using ``shell.inspect_response`` (:issue:`2812`)
- Handle HTTP 308 Permanent Redirect (:issue:`2844`)
- Add 522 and 524 to ``RETRY_HTTP_CODES`` (:issue:`2851`)
- Log versions information at startup (:issue:`2857`)
- ``scrapy.mail.MailSender`` now works in Python 3 (it requires Twisted 17.9.0)
- Connections to proxy servers are reused (:issue:`2743`)
- Add template for a downloader middleware (:issue:`2755`)
- Explicit message for NotImplementedError when parse callback not defined
(:issue:`2831`)
- CrawlerProcess got an option to disable installation of root log handler
(:issue:`2921`)
- LinkExtractor now ignores ``m4v`` extension by default
- Better log messages for responses over :setting:`DOWNLOAD_WARNSIZE` and
:setting:`DOWNLOAD_MAXSIZE` limits (:issue:`2927`)
- Show warning when a URL is put to ``Spider.allowed_domains`` instead of
a domain (:issue:`2250`).
Bug fixes
~~~~~~~~~
- Fix logging of settings overridden by ``custom_settings``;
**this is technically backward-incompatible** because the logger
changes from ``[scrapy.utils.log]`` to ``[scrapy.crawler]``, so please
update your log parsers if needed (:issue:`1343`)
- Default Scrapy User-Agent now uses https link to scrapy.org (:issue:`2983`).
**This is technically backward-incompatible**; override
:setting:`USER_AGENT` if you relied on old value.
- Fix PyPy and PyPy3 test failures, support them officially
(:issue:`2793`, :issue:`2935`, :issue:`2990`, :issue:`3050`, :issue:`2213`,
:issue:`3048`)
- Fix DNS resolver when ``DNSCACHE_ENABLED=False`` (:issue:`2811`)
- Add ``cryptography`` for Debian Jessie tox test env (:issue:`2848`)
- Add verification to check if Request callback is callable (:issue:`2766`)
- Port ``extras/qpsclient.py`` to Python 3 (:issue:`2849`)
- Use getfullargspec under the scenes for Python 3 to stop DeprecationWarning
(:issue:`2862`)
- Update deprecated test aliases (:issue:`2876`)
- Fix ``SitemapSpider`` support for alternate links (:issue:`2853`)
Docs
~~~~
- Added missing bullet point for the ``AUTOTHROTTLE_TARGET_CONCURRENCY``
setting. (:issue:`2756`)
- Update Contributing docs, document new support channels
(:issue:`2762`, issue:`3038`)
- Include references to Scrapy subreddit in the docs
- Fix broken links; use https:// for external links
(:issue:`2978`, :issue:`2982`, :issue:`2958`)
- Document CloseSpider extension better (:issue:`2759`)
- Use ``pymongo.collection.Collection.insert_one()`` in MongoDB example
(:issue:`2781`)
- Spelling mistake and typos
(:issue:`2828`, :issue:`2837`, :issue:`2884`, :issue:`2924`)
- Clarify ``CSVFeedSpider.headers`` documentation (:issue:`2826`)
- Document ``DontCloseSpider`` exception and clarify ``spider_idle``
(:issue:`2791`)
- Update "Releases" section in README (:issue:`2764`)
- Fix rst syntax in ``DOWNLOAD_FAIL_ON_DATALOSS`` docs (:issue:`2763`)
- Small fix in description of startproject arguments (:issue:`2866`)
- Clarify data types in Response.body docs (:issue:`2922`)
- Add a note about ``request.meta['depth']`` to DepthMiddleware docs (:issue:`2374`)
- Add a note about ``request.meta['dont_merge_cookies']`` to CookiesMiddleware
docs (:issue:`2999`)
- Up-to-date example of project structure (:issue:`2964`, :issue:`2976`)
- A better example of ItemExporters usage (:issue:`2989`)
- Document ``from_crawler`` methods for spider and downloader middlewares
(:issue:`3019`)
.. _release-1.4.0:
Scrapy 1.4.0 (2017-05-18)
-------------------------
Scrapy 1.4 does not bring that many breathtaking new features
but quite a few handy improvements nonetheless.
Scrapy now supports anonymous FTP sessions with customizable user and
password via the new :setting:`FTP_USER` and :setting:`FTP_PASSWORD` settings.
And if you're using Twisted version 17.1.0 or above, FTP is now available
with Python 3.
There's a new :meth:`response.follow ` method
for creating requests; **it is now a recommended way to create Requests
in Scrapy spiders**. This method makes it easier to write correct
spiders; ``response.follow`` has several advantages over creating
``scrapy.Request`` objects directly:
* it handles relative URLs;
* it works properly with non-ascii URLs on non-UTF8 pages;
* in addition to absolute and relative URLs it supports Selectors;
for ```` elements it can also extract their href values.
For example, instead of this::
for href in response.css('li.page a::attr(href)').extract():
url = response.urljoin(href)
yield scrapy.Request(url, self.parse, encoding=response.encoding)
One can now write this::
for a in response.css('li.page a'):
yield response.follow(a, self.parse)
Link extractors are also improved. They work similarly to what a regular
modern browser would do: leading and trailing whitespace are removed
from attributes (think ``href=" http://example.com"``) when building
``Link`` objects. This whitespace-stripping also happens for ``action``
attributes with ``FormRequest``.
**Please also note that link extractors do not canonicalize URLs by default
anymore.** This was puzzling users every now and then, and it's not what
browsers do in fact, so we removed that extra transformation on extracted
links.
For those of you wanting more control on the ``Referer:`` header that Scrapy
sends when following links, you can set your own ``Referrer Policy``.
Prior to Scrapy 1.4, the default ``RefererMiddleware`` would simply and
blindly set it to the URL of the response that generated the HTTP request
(which could leak information on your URL seeds).
By default, Scrapy now behaves much like your regular browser does.
And this policy is fully customizable with W3C standard values
(or with something really custom of your own if you wish).
See :setting:`REFERRER_POLICY` for details.
To make Scrapy spiders easier to debug, Scrapy logs more stats by default
in 1.4: memory usage stats, detailed retry stats, detailed HTTP error code
stats. A similar change is that HTTP cache path is also visible in logs now.
Last but not least, Scrapy now has the option to make JSON and XML items
more human-readable, with newlines between items and even custom indenting
offset, using the new :setting:`FEED_EXPORT_INDENT` setting.
Enjoy! (Or read on for the rest of changes in this release.)
Deprecations and Backward Incompatible Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Default to ``canonicalize=False`` in
:class:`scrapy.linkextractors.LinkExtractor
`
(:issue:`2537`, fixes :issue:`1941` and :issue:`1982`):
**warning, this is technically backward-incompatible**
- Enable memusage extension by default (:issue:`2539`, fixes :issue:`2187`);
**this is technically backward-incompatible** so please check if you have
any non-default ``MEMUSAGE_***`` options set.
- ``EDITOR`` environment variable now takes precedence over ``EDITOR``
option defined in settings.py (:issue:`1829`); Scrapy default settings
no longer depend on environment variables. **This is technically a backward
incompatible change**.
- ``Spider.make_requests_from_url`` is deprecated
(:issue:`1728`, fixes :issue:`1495`).
New Features
~~~~~~~~~~~~
- Accept proxy credentials in :reqmeta:`proxy` request meta key (:issue:`2526`)
- Support `brotli`_-compressed content; requires optional `brotlipy`_
(:issue:`2535`)
- New :ref:`response.follow ` shortcut
for creating requests (:issue:`1940`)
- Added ``flags`` argument and attribute to :class:`Request `
objects (:issue:`2047`)
- Support Anonymous FTP (:issue:`2342`)
- Added ``retry/count``, ``retry/max_reached`` and ``retry/reason_count/``
stats to :class:`RetryMiddleware `
(:issue:`2543`)
- Added ``httperror/response_ignored_count`` and ``httperror/response_ignored_status_count/``
stats to :class:`HttpErrorMiddleware `
(:issue:`2566`)
- Customizable :setting:`Referrer policy ` in
:class:`RefererMiddleware `
(:issue:`2306`)
- New ``data:`` URI download handler (:issue:`2334`, fixes :issue:`2156`)
- Log cache directory when HTTP Cache is used (:issue:`2611`, fixes :issue:`2604`)
- Warn users when project contains duplicate spider names (fixes :issue:`2181`)
- ``scrapy.utils.datatypes.CaselessDict`` now accepts ``Mapping`` instances and
not only dicts (:issue:`2646`)
- :ref:`Media downloads `, with
:class:`~scrapy.pipelines.files.FilesPipeline` or
:class:`~scrapy.pipelines.images.ImagesPipeline`, can now optionally handle
HTTP redirects using the new :setting:`MEDIA_ALLOW_REDIRECTS` setting
(:issue:`2616`, fixes :issue:`2004`)
- Accept non-complete responses from websites using a new
:setting:`DOWNLOAD_FAIL_ON_DATALOSS` setting (:issue:`2590`, fixes :issue:`2586`)
- Optional pretty-printing of JSON and XML items via
:setting:`FEED_EXPORT_INDENT` setting (:issue:`2456`, fixes :issue:`1327`)
- Allow dropping fields in ``FormRequest.from_response`` formdata when
``None`` value is passed (:issue:`667`)
- Per-request retry times with the new :reqmeta:`max_retry_times` meta key
(:issue:`2642`)
- ``python -m scrapy`` as a more explicit alternative to ``scrapy`` command
(:issue:`2740`)
.. _brotli: https://github.com/google/brotli
.. _brotlipy: https://github.com/python-hyper/brotlipy/
Bug fixes
~~~~~~~~~
- LinkExtractor now strips leading and trailing whitespaces from attributes
(:issue:`2547`, fixes :issue:`1614`)
- Properly handle whitespaces in action attribute in
:class:`~scrapy.http.FormRequest` (:issue:`2548`)
- Buffer CONNECT response bytes from proxy until all HTTP headers are received
(:issue:`2495`, fixes :issue:`2491`)
- FTP downloader now works on Python 3, provided you use Twisted>=17.1
(:issue:`2599`)
- Use body to choose response type after decompressing content (:issue:`2393`,
fixes :issue:`2145`)
- Always decompress ``Content-Encoding: gzip`` at :class:`HttpCompressionMiddleware
` stage (:issue:`2391`)
- Respect custom log level in ``Spider.custom_settings`` (:issue:`2581`,
fixes :issue:`1612`)
- 'make htmlview' fix for macOS (:issue:`2661`)
- Remove "commands" from the command list (:issue:`2695`)
- Fix duplicate Content-Length header for POST requests with empty body (:issue:`2677`)
- Properly cancel large downloads, i.e. above :setting:`DOWNLOAD_MAXSIZE` (:issue:`1616`)
- ImagesPipeline: fixed processing of transparent PNG images with palette
(:issue:`2675`)
Cleanups & Refactoring
~~~~~~~~~~~~~~~~~~~~~~
- Tests: remove temp files and folders (:issue:`2570`),
fixed ProjectUtilsTest on OS X (:issue:`2569`),
use portable pypy for Linux on Travis CI (:issue:`2710`)
- Separate building request from ``_requests_to_follow`` in CrawlSpider (:issue:`2562`)
- Remove “Python 3 progress” badge (:issue:`2567`)
- Add a couple more lines to ``.gitignore`` (:issue:`2557`)
- Remove bumpversion prerelease configuration (:issue:`2159`)
- Add codecov.yml file (:issue:`2750`)
- Set context factory implementation based on Twisted version (:issue:`2577`,
fixes :issue:`2560`)
- Add omitted ``self`` arguments in default project middleware template (:issue:`2595`)
- Remove redundant ``slot.add_request()`` call in ExecutionEngine (:issue:`2617`)
- Catch more specific ``os.error`` exception in
``scrapy.pipelines.files.FSFilesStore`` (:issue:`2644`)
- Change "localhost" test server certificate (:issue:`2720`)
- Remove unused ``MEMUSAGE_REPORT`` setting (:issue:`2576`)
Documentation
~~~~~~~~~~~~~
- Binary mode is required for exporters (:issue:`2564`, fixes :issue:`2553`)
- Mention issue with :meth:`FormRequest.from_response
` due to bug in lxml (:issue:`2572`)
- Use single quotes uniformly in templates (:issue:`2596`)
- Document :reqmeta:`ftp_user` and :reqmeta:`ftp_password` meta keys (:issue:`2587`)
- Removed section on deprecated ``contrib/`` (:issue:`2636`)
- Recommend Anaconda when installing Scrapy on Windows
(:issue:`2477`, fixes :issue:`2475`)
- FAQ: rewrite note on Python 3 support on Windows (:issue:`2690`)
- Rearrange selector sections (:issue:`2705`)
- Remove ``__nonzero__`` from :class:`~scrapy.selector.SelectorList`
docs (:issue:`2683`)
- Mention how to disable request filtering in documentation of
:setting:`DUPEFILTER_CLASS` setting (:issue:`2714`)
- Add sphinx_rtd_theme to docs setup readme (:issue:`2668`)
- Open file in text mode in JSON item writer example (:issue:`2729`)
- Clarify ``allowed_domains`` example (:issue:`2670`)
.. _release-1.3.3:
Scrapy 1.3.3 (2017-03-10)
-------------------------
Bug fixes
~~~~~~~~~
- Make ``SpiderLoader`` raise ``ImportError`` again by default for missing
dependencies and wrong :setting:`SPIDER_MODULES`.
These exceptions were silenced as warnings since 1.3.0.
A new setting is introduced to toggle between warning or exception if needed ;
see :setting:`SPIDER_LOADER_WARN_ONLY` for details.
.. _release-1.3.2:
Scrapy 1.3.2 (2017-02-13)
-------------------------
Bug fixes
~~~~~~~~~
- Preserve request class when converting to/from dicts (utils.reqser) (:issue:`2510`).
- Use consistent selectors for author field in tutorial (:issue:`2551`).
- Fix TLS compatibility in Twisted 17+ (:issue:`2558`)
.. _release-1.3.1:
Scrapy 1.3.1 (2017-02-08)
-------------------------
New features
~~~~~~~~~~~~
- Support ``'True'`` and ``'False'`` string values for boolean settings (:issue:`2519`);
you can now do something like ``scrapy crawl myspider -s REDIRECT_ENABLED=False``.
- Support kwargs with ``response.xpath()`` to use :ref:`XPath variables `
and ad-hoc namespaces declarations ;
this requires at least Parsel v1.1 (:issue:`2457`).
- Add support for Python 3.6 (:issue:`2485`).
- Run tests on PyPy (warning: some tests still fail, so PyPy is not supported yet).
Bug fixes
~~~~~~~~~
- Enforce ``DNS_TIMEOUT`` setting (:issue:`2496`).
- Fix :command:`view` command ; it was a regression in v1.3.0 (:issue:`2503`).
- Fix tests regarding ``*_EXPIRES settings`` with Files/Images pipelines (:issue:`2460`).
- Fix name of generated pipeline class when using basic project template (:issue:`2466`).
- Fix compatiblity with Twisted 17+ (:issue:`2496`, :issue:`2528`).
- Fix ``scrapy.Item`` inheritance on Python 3.6 (:issue:`2511`).
- Enforce numeric values for components order in ``SPIDER_MIDDLEWARES``,
``DOWNLOADER_MIDDLEWARES``, ``EXTENIONS`` and ``SPIDER_CONTRACTS`` (:issue:`2420`).
Documentation
~~~~~~~~~~~~~
- Reword Code of Coduct section and upgrade to Contributor Covenant v1.4
(:issue:`2469`).
- Clarify that passing spider arguments converts them to spider attributes
(:issue:`2483`).
- Document ``formid`` argument on ``FormRequest.from_response()`` (:issue:`2497`).
- Add .rst extension to README files (:issue:`2507`).
- Mention LevelDB cache storage backend (:issue:`2525`).
- Use ``yield`` in sample callback code (:issue:`2533`).
- Add note about HTML entities decoding with ``.re()/.re_first()`` (:issue:`1704`).
- Typos (:issue:`2512`, :issue:`2534`, :issue:`2531`).
Cleanups
~~~~~~~~
- Remove reduntant check in ``MetaRefreshMiddleware`` (:issue:`2542`).
- Faster checks in ``LinkExtractor`` for allow/deny patterns (:issue:`2538`).
- Remove dead code supporting old Twisted versions (:issue:`2544`).
.. _release-1.3.0:
Scrapy 1.3.0 (2016-12-21)
-------------------------
This release comes rather soon after 1.2.2 for one main reason:
it was found out that releases since 0.18 up to 1.2.2 (included) use
some backported code from Twisted (``scrapy.xlib.tx.*``),
even if newer Twisted modules are available.
Scrapy now uses ``twisted.web.client`` and ``twisted.internet.endpoints`` directly.
(See also cleanups below.)
As it is a major change, we wanted to get the bug fix out quickly
while not breaking any projects using the 1.2 series.
New Features
~~~~~~~~~~~~
- ``MailSender`` now accepts single strings as values for ``to`` and ``cc``
arguments (:issue:`2272`)
- ``scrapy fetch url``, ``scrapy shell url`` and ``fetch(url)`` inside
scrapy shell now follow HTTP redirections by default (:issue:`2290`);
See :command:`fetch` and :command:`shell` for details.
- ``HttpErrorMiddleware`` now logs errors with ``INFO`` level instead of ``DEBUG``;
this is technically **backward incompatible** so please check your log parsers.
- By default, logger names now use a long-form path, e.g. ``[scrapy.extensions.logstats]``,
instead of the shorter "top-level" variant of prior releases (e.g. ``[scrapy]``);
this is **backward incompatible** if you have log parsers expecting the short
logger name part. You can switch back to short logger names using :setting:`LOG_SHORT_NAMES`
set to ``True``.
Dependencies & Cleanups
~~~~~~~~~~~~~~~~~~~~~~~
- Scrapy now requires Twisted >= 13.1 which is the case for many Linux
distributions already.
- As a consequence, we got rid of ``scrapy.xlib.tx.*`` modules, which
copied some of Twisted code for users stuck with an "old" Twisted version
- ``ChunkedTransferMiddleware`` is deprecated and removed from the default
downloader middlewares.
.. _release-1.2.3:
Scrapy 1.2.3 (2017-03-03)
-------------------------
- Packaging fix: disallow unsupported Twisted versions in setup.py
.. _release-1.2.2:
Scrapy 1.2.2 (2016-12-06)
-------------------------
Bug fixes
~~~~~~~~~
- Fix a cryptic traceback when a pipeline fails on ``open_spider()`` (:issue:`2011`)
- Fix embedded IPython shell variables (fixing :issue:`396` that re-appeared
in 1.2.0, fixed in :issue:`2418`)
- A couple of patches when dealing with robots.txt:
- handle (non-standard) relative sitemap URLs (:issue:`2390`)
- handle non-ASCII URLs and User-Agents in Python 2 (:issue:`2373`)
Documentation
~~~~~~~~~~~~~
- Document ``"download_latency"`` key in ``Request``'s ``meta`` dict (:issue:`2033`)
- Remove page on (deprecated & unsupported) Ubuntu packages from ToC (:issue:`2335`)
- A few fixed typos (:issue:`2346`, :issue:`2369`, :issue:`2369`, :issue:`2380`)
and clarifications (:issue:`2354`, :issue:`2325`, :issue:`2414`)
Other changes
~~~~~~~~~~~~~
- Advertize `conda-forge`_ as Scrapy's official conda channel (:issue:`2387`)
- More helpful error messages when trying to use ``.css()`` or ``.xpath()``
on non-Text Responses (:issue:`2264`)
- ``startproject`` command now generates a sample ``middlewares.py`` file (:issue:`2335`)
- Add more dependencies' version info in ``scrapy version`` verbose output (:issue:`2404`)
- Remove all ``*.pyc`` files from source distribution (:issue:`2386`)
.. _conda-forge: https://anaconda.org/conda-forge/scrapy
.. _release-1.2.1:
Scrapy 1.2.1 (2016-10-21)
-------------------------
Bug fixes
~~~~~~~~~
- Include OpenSSL's more permissive default ciphers when establishing
TLS/SSL connections (:issue:`2314`).
- Fix "Location" HTTP header decoding on non-ASCII URL redirects (:issue:`2321`).
Documentation
~~~~~~~~~~~~~
- Fix JsonWriterPipeline example (:issue:`2302`).
- Various notes: :issue:`2330` on spider names,
:issue:`2329` on middleware methods processing order,
:issue:`2327` on getting multi-valued HTTP headers as lists.
Other changes
~~~~~~~~~~~~~
- Removed ``www.`` from ``start_urls`` in built-in spider templates (:issue:`2299`).
.. _release-1.2.0:
Scrapy 1.2.0 (2016-10-03)
-------------------------
New Features
~~~~~~~~~~~~
- New :setting:`FEED_EXPORT_ENCODING` setting to customize the encoding
used when writing items to a file.
This can be used to turn off ``\uXXXX`` escapes in JSON output.
This is also useful for those wanting something else than UTF-8
for XML or CSV output (:issue:`2034`).
- ``startproject`` command now supports an optional destination directory
to override the default one based on the project name (:issue:`2005`).
- New :setting:`SCHEDULER_DEBUG` setting to log requests serialization
failures (:issue:`1610`).
- JSON encoder now supports serialization of ``set`` instances (:issue:`2058`).
- Interpret ``application/json-amazonui-streaming`` as ``TextResponse`` (:issue:`1503`).
- ``scrapy`` is imported by default when using shell tools (:command:`shell`,
:ref:`inspect_response `) (:issue:`2248`).
Bug fixes
~~~~~~~~~
- DefaultRequestHeaders middleware now runs before UserAgent middleware
(:issue:`2088`). **Warning: this is technically backward incompatible**,
though we consider this a bug fix.
- HTTP cache extension and plugins that use the ``.scrapy`` data directory now
work outside projects (:issue:`1581`). **Warning: this is technically
backward incompatible**, though we consider this a bug fix.
- ``Selector`` does not allow passing both ``response`` and ``text`` anymore
(:issue:`2153`).
- Fixed logging of wrong callback name with ``scrapy parse`` (:issue:`2169`).
- Fix for an odd gzip decompression bug (:issue:`1606`).
- Fix for selected callbacks when using ``CrawlSpider`` with :command:`scrapy parse `
(:issue:`2225`).
- Fix for invalid JSON and XML files when spider yields no items (:issue:`872`).
- Implement ``flush()`` fpr ``StreamLogger`` avoiding a warning in logs (:issue:`2125`).
Refactoring
~~~~~~~~~~~
- ``canonicalize_url`` has been moved to `w3lib.url`_ (:issue:`2168`).
.. _w3lib.url: https://w3lib.readthedocs.io/en/latest/w3lib.html#w3lib.url.canonicalize_url
Tests & Requirements
~~~~~~~~~~~~~~~~~~~~
Scrapy's new requirements baseline is Debian 8 "Jessie". It was previously
Ubuntu 12.04 Precise.
What this means in practice is that we run continuous integration tests
with these (main) packages versions at a minimum:
Twisted 14.0, pyOpenSSL 0.14, lxml 3.4.
Scrapy may very well work with older versions of these packages
(the code base still has switches for older Twisted versions for example)
but it is not guaranteed (because it's not tested anymore).
Documentation
~~~~~~~~~~~~~
- Grammar fixes: :issue:`2128`, :issue:`1566`.
- Download stats badge removed from README (:issue:`2160`).
- New scrapy :ref:`architecture diagram ` (:issue:`2165`).
- Updated ``Response`` parameters documentation (:issue:`2197`).
- Reworded misleading :setting:`RANDOMIZE_DOWNLOAD_DELAY` description (:issue:`2190`).
- Add StackOverflow as a support channel (:issue:`2257`).
.. _release-1.1.4:
Scrapy 1.1.4 (2017-03-03)
-------------------------
- Packaging fix: disallow unsupported Twisted versions in setup.py
.. _release-1.1.3:
Scrapy 1.1.3 (2016-09-22)
-------------------------
Bug fixes
~~~~~~~~~
- Class attributes for subclasses of ``ImagesPipeline`` and ``FilesPipeline``
work as they did before 1.1.1 (:issue:`2243`, fixes :issue:`2198`)
Documentation
~~~~~~~~~~~~~
- :ref:`Overview ` and :ref:`tutorial `
rewritten to use http://toscrape.com websites
(:issue:`2236`, :issue:`2249`, :issue:`2252`).
.. _release-1.1.2:
Scrapy 1.1.2 (2016-08-18)
-------------------------
Bug fixes
~~~~~~~~~
- Introduce a missing :setting:`IMAGES_STORE_S3_ACL` setting to override
the default ACL policy in ``ImagesPipeline`` when uploading images to S3
(note that default ACL policy is "private" -- instead of "public-read" --
since Scrapy 1.1.0)
- :setting:`IMAGES_EXPIRES` default value set back to 90
(the regression was introduced in 1.1.1)
.. _release-1.1.1:
Scrapy 1.1.1 (2016-07-13)
-------------------------
Bug fixes
~~~~~~~~~
- Add "Host" header in CONNECT requests to HTTPS proxies (:issue:`2069`)
- Use response ``body`` when choosing response class
(:issue:`2001`, fixes :issue:`2000`)
- Do not fail on canonicalizing URLs with wrong netlocs
(:issue:`2038`, fixes :issue:`2010`)
- a few fixes for ``HttpCompressionMiddleware`` (and ``SitemapSpider``):
- Do not decode HEAD responses (:issue:`2008`, fixes :issue:`1899`)
- Handle charset parameter in gzip Content-Type header
(:issue:`2050`, fixes :issue:`2049`)
- Do not decompress gzip octet-stream responses
(:issue:`2065`, fixes :issue:`2063`)
- Catch (and ignore with a warning) exception when verifying certificate
against IP-address hosts (:issue:`2094`, fixes :issue:`2092`)
- Make ``FilesPipeline`` and ``ImagesPipeline`` backward compatible again
regarding the use of legacy class attributes for customization
(:issue:`1989`, fixes :issue:`1985`)
New features
~~~~~~~~~~~~
- Enable genspider command outside project folder (:issue:`2052`)
- Retry HTTPS CONNECT ``TunnelError`` by default (:issue:`1974`)
Documentation
~~~~~~~~~~~~~
- ``FEED_TEMPDIR`` setting at lexicographical position (:commit:`9b3c72c`)
- Use idiomatic ``.extract_first()`` in overview (:issue:`1994`)
- Update years in copyright notice (:commit:`c2c8036`)
- Add information and example on errbacks (:issue:`1995`)
- Use "url" variable in downloader middleware example (:issue:`2015`)
- Grammar fixes (:issue:`2054`, :issue:`2120`)
- New FAQ entry on using BeautifulSoup in spider callbacks (:issue:`2048`)
- Add notes about scrapy not working on Windows with Python 3 (:issue:`2060`)
- Encourage complete titles in pull requests (:issue:`2026`)
Tests
~~~~~
- Upgrade py.test requirement on Travis CI and Pin pytest-cov to 2.2.1 (:issue:`2095`)
.. _release-1.1.0:
Scrapy 1.1.0 (2016-05-11)
-------------------------
This 1.1 release brings a lot of interesting features and bug fixes:
- Scrapy 1.1 has beta Python 3 support (requires Twisted >= 15.5). See
:ref:`news_betapy3` for more details and some limitations.
- Hot new features:
- Item loaders now support nested loaders (:issue:`1467`).
- ``FormRequest.from_response`` improvements (:issue:`1382`, :issue:`1137`).
- Added setting :setting:`AUTOTHROTTLE_TARGET_CONCURRENCY` and improved
AutoThrottle docs (:issue:`1324`).
- Added ``response.text`` to get body as unicode (:issue:`1730`).
- Anonymous S3 connections (:issue:`1358`).
- Deferreds in downloader middlewares (:issue:`1473`). This enables better
robots.txt handling (:issue:`1471`).
- HTTP caching now follows RFC2616 more closely, added settings
:setting:`HTTPCACHE_ALWAYS_STORE` and
:setting:`HTTPCACHE_IGNORE_RESPONSE_CACHE_CONTROLS` (:issue:`1151`).
- Selectors were extracted to the parsel_ library (:issue:`1409`). This means
you can use Scrapy Selectors without Scrapy and also upgrade the
selectors engine without needing to upgrade Scrapy.
- HTTPS downloader now does TLS protocol negotiation by default,
instead of forcing TLS 1.0. You can also set the SSL/TLS method
using the new :setting:`DOWNLOADER_CLIENT_TLS_METHOD`.
- These bug fixes may require your attention:
- Don't retry bad requests (HTTP 400) by default (:issue:`1289`).
If you need the old behavior, add ``400`` to :setting:`RETRY_HTTP_CODES`.
- Fix shell files argument handling (:issue:`1710`, :issue:`1550`).
If you try ``scrapy shell index.html`` it will try to load the URL http://index.html,
use ``scrapy shell ./index.html`` to load a local file.
- Robots.txt compliance is now enabled by default for newly-created projects
(:issue:`1724`). Scrapy will also wait for robots.txt to be downloaded
before proceeding with the crawl (:issue:`1735`). If you want to disable
this behavior, update :setting:`ROBOTSTXT_OBEY` in ``settings.py`` file
after creating a new project.
- Exporters now work on unicode, instead of bytes by default (:issue:`1080`).
If you use :class:`~scrapy.exporters.PythonItemExporter`, you may want to
update your code to disable binary mode which is now deprecated.
- Accept XML node names containing dots as valid (:issue:`1533`).
- When uploading files or images to S3 (with ``FilesPipeline`` or
``ImagesPipeline``), the default ACL policy is now "private" instead
of "public" **Warning: backward incompatible!**.
You can use :setting:`FILES_STORE_S3_ACL` to change it.
- We've reimplemented ``canonicalize_url()`` for more correct output,
especially for URLs with non-ASCII characters (:issue:`1947`).
This could change link extractors output compared to previous scrapy versions.
This may also invalidate some cache entries you could still have from pre-1.1 runs.
**Warning: backward incompatible!**.
Keep reading for more details on other improvements and bug fixes.
.. _news_betapy3:
Beta Python 3 Support
~~~~~~~~~~~~~~~~~~~~~
We have been `hard at work to make Scrapy run on Python 3
`_. As a result, now
you can run spiders on Python 3.3, 3.4 and 3.5 (Twisted >= 15.5 required). Some
features are still missing (and some may never be ported).
Almost all builtin extensions/middlewares are expected to work.
However, we are aware of some limitations in Python 3:
- Scrapy does not work on Windows with Python 3
- Sending emails is not supported
- FTP download handler is not supported
- Telnet console is not supported
Additional New Features and Enhancements
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Scrapy now has a `Code of Conduct`_ (:issue:`1681`).
- Command line tool now has completion for zsh (:issue:`934`).
- Improvements to ``scrapy shell``:
- Support for bpython and configure preferred Python shell via
``SCRAPY_PYTHON_SHELL`` (:issue:`1100`, :issue:`1444`).
- Support URLs without scheme (:issue:`1498`)
**Warning: backward incompatible!**
- Bring back support for relative file path (:issue:`1710`, :issue:`1550`).
- Added :setting:`MEMUSAGE_CHECK_INTERVAL_SECONDS` setting to change default check
interval (:issue:`1282`).
- Download handlers are now lazy-loaded on first request using their
scheme (:issue:`1390`, :issue:`1421`).
- HTTPS download handlers do not force TLS 1.0 anymore; instead,
OpenSSL's ``SSLv23_method()/TLS_method()`` is used allowing to try
negotiating with the remote hosts the highest TLS protocol version
it can (:issue:`1794`, :issue:`1629`).
- ``RedirectMiddleware`` now skips the status codes from
``handle_httpstatus_list`` on spider attribute
or in ``Request``'s ``meta`` key (:issue:`1334`, :issue:`1364`,
:issue:`1447`).
- Form submission:
- now works with ``