Skip to content

Support proxy mode - #304

Open
AdrianAtZyte wants to merge 44 commits into
scrapy-plugins:mainfrom
AdrianAtZyte:proxy-mode
Open

Support proxy mode#304
AdrianAtZyte wants to merge 44 commits into
scrapy-plugins:mainfrom
AdrianAtZyte:proxy-mode

Conversation

@AdrianAtZyte

@AdrianAtZyte AdrianAtZyte commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

I have manually tested the changes, and in a simple books.toscrape.com spider things work both with http and proxy transport very similarly.

Too similarly, in fact. I was hoping for a simple, ~30 requests with 1 concurrency to show a lower wall time with proxy mode, but it was the opposite, although by a small margin.

Opus then run a better benchmark (interleaving http and proxy, 3 runs each, concurrency 8, 211 requests each run) that did show proxy mode to offer ~43% lower wall time and ~46% lower latency. Did not measure network, but it should be a given that proxy mode is better there due to the base64 encoding of non-browser requests.

Caveats:

  • I have discarded implementing proxy mode support in python-zyte-api. However, it may be worth considering. It would definitely simplify stat handling.

  • I have kept out of scope compatibility and a migration path from scrapy-zyte-smartproxy. Besides this PR being complex enough as it is, I feel like we should wait for proxy mode here to prove itself for a while, improving it based on user feedback, and only once we feel this is the best way to use proxy mode, make migrating from scrapy-zyte-smartproxy as easy as possible (e.g. make it so that simply uninstalling scrapy-zyte-smartproxy automatically makes scrapy-zyte-api take over, being functionally equivalent, with no mandatory changes [only migration warnings]).

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.62%. Comparing base (1701567) to head (8780c6b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #304      +/-   ##
==========================================
+ Coverage   97.50%   99.62%   +2.12%     
==========================================
  Files          15       19       +4     
  Lines        2404     2936     +532     
  Branches      439      530      +91     
==========================================
+ Hits         2344     2925     +581     
+ Misses         31        5      -26     
+ Partials       29        6      -23     
Files with missing lines Coverage Δ
scrapy_zyte_api/_cookies.py 100.00% <100.00%> (+16.66%) ⬆️
scrapy_zyte_api/_params.py 100.00% <100.00%> (+0.63%) ⬆️
scrapy_zyte_api/_proxy.py 100.00% <100.00%> (ø)
scrapy_zyte_api/_request_fingerprinter.py 99.44% <100.00%> (+3.44%) ⬆️
scrapy_zyte_api/_request_transport.py 100.00% <100.00%> (ø)
scrapy_zyte_api/_request_type.py 100.00% <100.00%> (ø)
scrapy_zyte_api/_session.py 100.00% <100.00%> (+0.47%) ⬆️
scrapy_zyte_api/_utils.py 100.00% <100.00%> (ø)
scrapy_zyte_api/handler.py 100.00% <100.00%> (+3.30%) ⬆️
scrapy_zyte_api/providers.py 99.20% <100.00%> (+3.91%) ⬆️
... and 2 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AdrianAtZyte
AdrianAtZyte requested review from kmike and wRAR June 26, 2026 08:04
@AdrianAtZyte
AdrianAtZyte marked this pull request as ready for review June 26, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant