<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>ProxyMesh Blog - scrapy</title><link href="https://proxymesh.com/posts/" rel="alternate"/><link href="https://proxymesh.com/posts/feeds/tag-scrapy.atom.xml" rel="self"/><id>https://proxymesh.com/posts/</id><updated>2026-11-16T00:00:00+00:00</updated><subtitle>Features, open-source releases, proxy and scraping news from ProxyMesh.</subtitle><entry><title>scrapy-proxy-headers 0.3.0 works with Scrapy 2.20</title><link href="https://proxymesh.com/posts/scrapy-proxy-headers-0-3-0/" rel="alternate"/><published>2026-11-16T00:00:00+00:00</published><updated>2026-11-16T00:00:00+00:00</updated><author><name>ProxyMesh</name></author><id>tag:proxymesh.com,2026-11-16:/posts/scrapy-proxy-headers-0-3-0/</id><summary type="html">&lt;p&gt;scrapy-proxy-headers 0.3.0 adds Scrapy 2.20 support and has no upper Scrapy cap. It requires Python 3.10 or newer, so Python 3.8 and 3.9 stay on 0.2.2.&lt;/p&gt;</summary><content type="html">&lt;p&gt;scrapy-proxy-headers 0.3.0 runs on Scrapy 2.20 and newer. If you run Scrapy
2.17 or later on Python 3.10 or newer, install 0.3.0. If you must stay on
Python 3.8 or 3.9, stay on
&lt;a href="../scrapy-proxy-headers-0-2-2/"&gt;0.2.2&lt;/a&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pip&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;-U&lt;span class="w"&gt; &lt;/span&gt;scrapy-proxy-headers
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id="requirements-python-310-and-scrapy-217"&gt;Requirements: Python 3.10+ and Scrapy 2.17+&lt;/h2&gt;
&lt;p&gt;0.3.0 requires Python 3.10 or newer, matching Scrapy 2.17.0, and
&lt;code&gt;scrapy&amp;gt;=2.17.0&lt;/code&gt; with no upper cap. 0.2.2 is the last release for Python 3.8
and 3.9. Scrapy 2.20.0 and Scrapy master require Python 3.11 or newer, because
&lt;a href="https://docs.scrapy.org/en/latest/news.html#scrapy-2-20-0-2026-11-06"&gt;Scrapy 2.20&lt;/a&gt;
dropped support for Python 3.10.&lt;/p&gt;
&lt;h2 id="scrapy-220-support"&gt;Scrapy 2.20 support&lt;/h2&gt;
&lt;p&gt;0.3.0 works with the proxy headers support built into
&lt;a href="https://docs.scrapy.org/en/latest/news.html#scrapy-2-20-0-2026-11-06"&gt;Scrapy 2.20.0&lt;/a&gt;.
You send headers the same way, with &lt;code&gt;proxy_headers&lt;/code&gt; in your request meta, and
you still get the &lt;code&gt;X-ProxyMesh-IP&lt;/code&gt; response header, which Scrapy alone doesn't
give you.&lt;/p&gt;
&lt;p&gt;Keep &lt;code&gt;DOWNLOAD_HANDLERS&lt;/code&gt; set to &lt;code&gt;scrapy_proxy_headers.HTTP11ProxyDownloadHandler&lt;/code&gt;
if your spider reads &lt;code&gt;X-ProxyMesh-IP&lt;/code&gt; from &lt;code&gt;response.headers&lt;/code&gt;. On Scrapy 2.20
and newer, a project that only sends &lt;code&gt;proxy_headers&lt;/code&gt; can omit the handler and
keep the same meta value.&lt;/p&gt;
&lt;h2 id="different-headers-stay-separate"&gt;Different headers stay separate&lt;/h2&gt;
&lt;p&gt;0.3.0 keeps &lt;code&gt;X-ProxyMesh-IP&lt;/code&gt; matched to the &lt;code&gt;proxy_headers&lt;/code&gt; you sent, so
requests with different headers never share another request's value. On Scrapy
2.17 through 2.19, each set of &lt;code&gt;proxy_headers&lt;/code&gt; also gets its own connection to
the proxy. Those Scrapy releases otherwise reuse one connection per proxy, so a
later request with different headers could skip its own.&lt;/p&gt;
&lt;h2 id="example-choose-a-country-and-read-the-proxy-ip"&gt;Example: choose a country and read the proxy IP&lt;/h2&gt;
&lt;p&gt;Scrapy 2.16 removed &lt;code&gt;start_requests()&lt;/code&gt;, so a spider that only defines it sends
no requests on any Scrapy version 0.3.0 supports. Define &lt;code&gt;async def start()&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;scrapy&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;CountrySpider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scrapy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Spider&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;country&amp;quot;&lt;/span&gt;
    &lt;span class="n"&gt;custom_settings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;&amp;quot;DOWNLOAD_HANDLERS&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="s2"&gt;&amp;quot;https&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;scrapy_proxy_headers.HTTP11ProxyDownloadHandler&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;scrapy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="s2"&gt;&amp;quot;https://api.ipify.org?format=json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="c1"&gt;# X-ProxyMesh-Country works on the World and Open proxies.&lt;/span&gt;
                &lt;span class="s2"&gt;&amp;quot;proxy&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;http://USERNAME:PASSWORD@PROXY_HOST:PORT&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="s2"&gt;&amp;quot;proxy_headers&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;X-ProxyMesh-Country&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;DE&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;proxy_ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;X-ProxyMesh-IP&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;proxy_ip&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;proxy_ip&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;proxy_ip&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Only some ProxyMesh proxies honor &lt;code&gt;X-ProxyMesh-Country&lt;/code&gt;. The
&lt;a href="https://docs.proxymesh.com/article/7-request-response-headers"&gt;request and response headers article&lt;/a&gt;
lists every header ProxyMesh accepts and returns, and the
&lt;a href="https://docs.proxymesh.com/article/4-python-proxy-configuration#Scrapy--send-and-read"&gt;Python proxy configuration article&lt;/a&gt;
covers the Scrapy setup.&lt;/p&gt;
&lt;p&gt;Install it from
&lt;a href="https://pypi.org/project/scrapy-proxy-headers/0.3.0/"&gt;scrapy-proxy-headers 0.3.0 on PyPI&lt;/a&gt;.
The &lt;a href="https://github.com/proxymesh/scrapy-proxy-headers/releases/tag/v0.3.0"&gt;GitHub release notes&lt;/a&gt;
and the &lt;a href="https://github.com/proxymesh/scrapy-proxy-headers/compare/v0.2.2...v0.3.0"&gt;full diff from 0.2.2&lt;/a&gt;
list the changes. Usage is covered in the
&lt;a href="https://scrapy-proxy-headers.readthedocs.io/"&gt;scrapy-proxy-headers documentation&lt;/a&gt;.&lt;/p&gt;</content><category term="Releases"/><category term="release"/><category term="scrapy"/><category term="python"/></entry><entry><title>scrapy-proxy-headers 0.2.2 hardens CONNECT header handling</title><link href="https://proxymesh.com/posts/scrapy-proxy-headers-0-2-2/" rel="alternate"/><published>2026-11-12T00:00:00+00:00</published><updated>2026-11-12T00:00:00+00:00</updated><author><name>ProxyMesh</name></author><id>tag:proxymesh.com,2026-11-12:/posts/scrapy-proxy-headers-0-2-2/</id><summary type="html">&lt;p&gt;scrapy-proxy-headers 0.2.2 hardens CONNECT header handling and requires Scrapy 2.17.0, which patches a high-severity advisory. It runs on Scrapy 2.17 to 2.19.&lt;/p&gt;</summary><content type="html">&lt;p&gt;scrapy-proxy-headers 0.2.2 hardens how the package handles proxy headers, and
it requires Scrapy 2.17.0 or later, the release that patches a
high-severity advisory. If you run Scrapy 2.17 through 2.19 on Python 3.8 or
newer, upgrade from 0.2.1. Your settings and request meta don't need to change.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pip&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;-U&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;scrapy-proxy-headers==0.2.2&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id="security-connect-header-handling"&gt;Security: CONNECT header handling&lt;/h2&gt;
&lt;p&gt;0.2.2 rejects a line break (CR or LF) in a &lt;code&gt;proxy_headers&lt;/code&gt; name or value and
raises &lt;code&gt;ValueError&lt;/code&gt;, so a header can't add extra lines to the request the
package sends to the proxy. It also reads the proxy's reply more carefully: a
header split across network packets stays intact, and bytes after the headers
aren't treated as headers.&lt;/p&gt;
&lt;p&gt;When the package copies the proxy's headers onto the HTTPS response, it leaves
the website's headers unchanged. 0.2.1 replaces a website header such as
&lt;code&gt;Content-Type&lt;/code&gt; or &lt;code&gt;Set-Cookie&lt;/code&gt; when the proxy sends a header with the same
name. New proxy headers such as &lt;code&gt;X-ProxyMesh-IP&lt;/code&gt; are still copied.&lt;/p&gt;
&lt;h2 id="security-scrapy-2170-is-required"&gt;Security: Scrapy 2.17.0 is required&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://github.com/advisories/GHSA-76g3-c3x4-crvx"&gt;CVE-2026-84366&lt;/a&gt; is a
high-severity advisory (CVSS 7.4) for Scrapy versions before 2.17.0.
Before 2.17.0, Scrapy's S3 download handler sends signed &lt;code&gt;s3://&lt;/code&gt; requests over
plaintext HTTP unless &lt;code&gt;request.meta["is_secure"]&lt;/code&gt; is true, which exposes the
request path, the AWS &lt;code&gt;Authorization&lt;/code&gt; header, and the response to a network
attacker. If you make
&lt;code&gt;s3://&lt;/code&gt; requests with AWS credentials, this affects you.
&lt;a href="https://docs.scrapy.org/en/latest/news.html#scrapy-2-17-0-2026-07-07"&gt;Scrapy 2.17.0&lt;/a&gt;
uses HTTPS by default. 0.2.2 requires &lt;code&gt;scrapy&amp;gt;=2.17.0&lt;/code&gt;, so the upgrade command
above also upgrades Scrapy when the environment has an older version.&lt;/p&gt;
&lt;h2 id="requirements-scrapy-217-to-219-python-38"&gt;Requirements: Scrapy 2.17 to 2.19, Python 3.8+&lt;/h2&gt;
&lt;p&gt;0.2.2 requires Scrapy 2.17.0 up to, but not including, 2.20, and Python 3.8 or
newer. It doesn't install or run on
&lt;a href="https://docs.scrapy.org/en/latest/news.html#scrapy-2-20-0-2026-11-06"&gt;Scrapy 2.20&lt;/a&gt;,
which adds built-in proxy headers support. Install
&lt;a href="../scrapy-proxy-headers-0-3-0/"&gt;scrapy-proxy-headers 0.3.0&lt;/a&gt;
for Scrapy 2.20, or if you run Python 3.10 or newer.&lt;/p&gt;
&lt;h2 id="example-choose-a-country-and-read-the-proxy-ip"&gt;Example: choose a country and read the proxy IP&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;scrapy&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;CountrySpider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scrapy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Spider&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;country&amp;quot;&lt;/span&gt;
    &lt;span class="n"&gt;custom_settings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;&amp;quot;DOWNLOAD_HANDLERS&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="s2"&gt;&amp;quot;https&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;scrapy_proxy_headers.HTTP11ProxyDownloadHandler&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;scrapy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="s2"&gt;&amp;quot;https://api.ipify.org?format=json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="c1"&gt;# X-ProxyMesh-Country works on the World and Open proxies.&lt;/span&gt;
                &lt;span class="s2"&gt;&amp;quot;proxy&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;http://USERNAME:PASSWORD@PROXY_HOST:PORT&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="s2"&gt;&amp;quot;proxy_headers&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;X-ProxyMesh-Country&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;DE&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;proxy_ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;X-ProxyMesh-IP&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;proxy_ip&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;proxy_ip&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;proxy_ip&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The &lt;a href="https://docs.proxymesh.com/article/7-request-response-headers"&gt;request and response headers article&lt;/a&gt;
lists every header ProxyMesh accepts and returns. The
&lt;a href="https://docs.proxymesh.com/article/4-python-proxy-configuration#Scrapy--send-and-read"&gt;Python proxy configuration article&lt;/a&gt;
covers the Scrapy setup.&lt;/p&gt;
&lt;p&gt;Install it from
&lt;a href="https://pypi.org/project/scrapy-proxy-headers/0.2.2/"&gt;scrapy-proxy-headers 0.2.2 on PyPI&lt;/a&gt;.
The &lt;a href="https://github.com/proxymesh/scrapy-proxy-headers/releases/tag/v0.2.2"&gt;GitHub release notes&lt;/a&gt;
and the &lt;a href="https://github.com/proxymesh/scrapy-proxy-headers/compare/v0.2.1...v0.2.2"&gt;full diff from 0.2.1&lt;/a&gt;
list the changes. Usage is covered in the
&lt;a href="https://scrapy-proxy-headers.readthedocs.io/"&gt;scrapy-proxy-headers documentation&lt;/a&gt;.&lt;/p&gt;</content><category term="Releases"/><category term="release"/><category term="scrapy"/><category term="python"/><category term="security"/></entry><entry><title>scrapy-proxy-headers 0.2.1 works with Scrapy 2.16 and later</title><link href="https://proxymesh.com/posts/scrapy-proxy-headers-0-2-1/" rel="alternate"/><published>2026-09-01T00:00:00+00:00</published><updated>2026-09-01T00:00:00+00:00</updated><author><name>ProxyMesh</name></author><id>tag:proxymesh.com,2026-09-01:/posts/scrapy-proxy-headers-0-2-1/</id><summary type="html">&lt;p&gt;scrapy-proxy-headers 0.2.1 fixes an import error on Scrapy 2.16 and later, and requires Scrapy 2.14.2 to avoid a high-severity Scrapy advisory.&lt;/p&gt;</summary><content type="html">&lt;p&gt;scrapy-proxy-headers 0.2.1 fixes the package on Scrapy 2.16 and later, where
version 0.2.0 fails to load. It also raises the minimum Scrapy version to
2.14.2, the release that patches a high-severity &lt;code&gt;Referrer-Policy&lt;/code&gt;
vulnerability. If you run Scrapy 2.16 or newer, or still have Scrapy 2.14.1
installed, upgrade now. Your settings and spider code don't need to change.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pip&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;-U&lt;span class="w"&gt; &lt;/span&gt;scrapy-proxy-headers
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id="why-020-broke-on-scrapy-216"&gt;Why 0.2.0 broke on Scrapy 2.16&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://docs.scrapy.org/en/latest/news.html#release-2-16-0"&gt;Scrapy 2.16&lt;/a&gt; made
several classes in its HTTP/1.1 download handler private, including
&lt;code&gt;TunnelingAgent&lt;/code&gt; and &lt;code&gt;ScrapyAgent&lt;/code&gt;. scrapy-proxy-headers 0.2.0 imported them by
their old public names, so on Scrapy 2.16 through 2.18 Scrapy can't load
&lt;code&gt;HTTP11ProxyDownloadHandler&lt;/code&gt;. Every HTTPS request then fails with an error like
this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;NotSupported: Unsupported URL scheme &amp;#39;https&amp;#39;: cannot import name &amp;#39;TunnelingAgent&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Version 0.2.1 looks up both the old and the new names, so one release works on
every Scrapy version from 2.14.2 to 2.18. It also builds its own tunneling agent
for HTTPS requests sent through a proxy, so your &lt;code&gt;proxy_headers&lt;/code&gt; still go out
with the &lt;code&gt;CONNECT&lt;/code&gt; request on newer Scrapy releases.&lt;/p&gt;
&lt;h2 id="security-scrapy-2142-is-now-required"&gt;Security: Scrapy 2.14.2 is now required&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://github.com/advisories/GHSA-cwxj-rr6w-m6w7"&gt;GHSA-cwxj-rr6w-m6w7&lt;/a&gt; is a
high-severity advisory for Scrapy 1.4.0 through 2.14.1. When a site sent a
&lt;code&gt;Referrer-Policy&lt;/code&gt; header that looked like a Python import path, Scrapy imported
that object and called it. A malicious site could use this to make your
crawler call something like &lt;code&gt;sys.exit&lt;/code&gt; and stop.
&lt;a href="https://docs.scrapy.org/en/latest/news.html#scrapy-2-14-2-2026-03-12"&gt;Scrapy 2.14.2&lt;/a&gt;
fixes it.&lt;/p&gt;
&lt;p&gt;scrapy-proxy-headers 0.2.0 still allowed Scrapy 2.14.1. Version 0.2.1 requires
&lt;code&gt;scrapy&amp;gt;=2.14.2&lt;/code&gt;, so &lt;code&gt;pip install -U scrapy-proxy-headers&lt;/code&gt; also upgrades Scrapy
if you're on the affected release.&lt;/p&gt;
&lt;h2 id="example-choose-a-country-and-read-the-proxy-ip"&gt;Example: choose a country and read the proxy IP&lt;/h2&gt;
&lt;p&gt;Headers you set on a Scrapy request travel inside the encrypted HTTPS tunnel,
so the proxy never sees them. scrapy-proxy-headers sends &lt;code&gt;proxy_headers&lt;/code&gt; in the
&lt;code&gt;CONNECT&lt;/code&gt; request instead, and copies the proxy's reply headers into
&lt;code&gt;response.headers&lt;/code&gt;. With ProxyMesh, pick a country with &lt;code&gt;X-ProxyMesh-Country&lt;/code&gt;
and log which IP served each request from &lt;code&gt;X-ProxyMesh-IP&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;scrapy&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;CountrySpider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scrapy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Spider&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;country&amp;quot;&lt;/span&gt;
    &lt;span class="n"&gt;custom_settings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;&amp;quot;DOWNLOAD_HANDLERS&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="s2"&gt;&amp;quot;https&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;scrapy_proxy_headers.HTTP11ProxyDownloadHandler&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;scrapy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="s2"&gt;&amp;quot;https://api.ipify.org?format=json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="c1"&gt;# X-ProxyMesh-Country works on the World and Open proxies.&lt;/span&gt;
                &lt;span class="s2"&gt;&amp;quot;proxy&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;http://USERNAME:PASSWORD@PROXY_HOST:PORT&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="s2"&gt;&amp;quot;proxy_headers&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;X-ProxyMesh-Country&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;DE&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;proxy_ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;X-ProxyMesh-IP&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;proxy_ip&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;proxy_ip&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;proxy_ip&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;See &lt;a href="https://docs.proxymesh.com/article/7-request-response-headers"&gt;Proxy Server Request &amp;amp; Response Headers&lt;/a&gt;
for every header ProxyMesh accepts and returns.&lt;/p&gt;
&lt;h2 id="other-changes"&gt;Other changes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;An &lt;code&gt;https://&lt;/code&gt; proxy URL with an HTTPS destination now raises
  &lt;code&gt;NotImplementedError&lt;/code&gt;, the same limit Scrapy 2.16 added to its own handler.
  ProxyMesh proxy URLs use &lt;code&gt;http://&lt;/code&gt;, so this doesn't affect ProxyMesh setups.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;HTTP11ProxyDownloadHandler.download_request()&lt;/code&gt; is now a coroutine, matching
  Scrapy's current download handler API. This only matters if you subclass the
  handler.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Install it from
&lt;a href="https://pypi.org/project/scrapy-proxy-headers/0.2.1/"&gt;scrapy-proxy-headers 0.2.1 on PyPI&lt;/a&gt;.
The &lt;a href="https://github.com/proxymesh/scrapy-proxy-headers/releases/tag/v0.2.1"&gt;GitHub release notes&lt;/a&gt;
and the &lt;a href="https://github.com/proxymesh/scrapy-proxy-headers/compare/v0.2.0...v0.2.1"&gt;full diff from 0.2.0&lt;/a&gt;
list the changes. Usage is covered in the
&lt;a href="https://scrapy-proxy-headers.readthedocs.io/"&gt;scrapy-proxy-headers documentation&lt;/a&gt;.&lt;/p&gt;</content><category term="Releases"/><category term="release"/><category term="scrapy"/><category term="python"/><category term="security"/></entry></feed>