proxy-scraper-cli 1.17.0__tar.gz → 1.19.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/PKG-INFO +7 -2
  2. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/README.md +6 -1
  3. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxy_scraper_cli.egg-info/PKG-INFO +7 -2
  4. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxy_scraper_cli.egg-info/SOURCES.txt +2 -0
  5. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/__init__.py +1 -1
  6. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/action.py +4 -2
  7. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/agent.py +8 -6
  8. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/api.py +9 -5
  9. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/checker.py +1 -0
  10. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/cli.py +6 -3
  11. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/pages.py +5 -3
  12. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/publish.py +8 -6
  13. proxy_scraper_cli-1.19.0/proxyscraper/ranking.py +44 -0
  14. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/server/pool.py +27 -5
  15. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/site/index.html +8 -4
  16. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_action.py +13 -4
  17. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_pick.py +7 -0
  18. proxy_scraper_cli-1.19.0/tests/test_speed_ranking.py +108 -0
  19. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/LICENSE +0 -0
  20. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxy_scraper_cli.egg-info/dependency_links.txt +0 -0
  21. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxy_scraper_cli.egg-info/entry_points.txt +0 -0
  22. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxy_scraper_cli.egg-info/requires.txt +0 -0
  23. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxy_scraper_cli.egg-info/top_level.txt +0 -0
  24. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/__main__.py +0 -0
  25. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/app.py +0 -0
  26. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/asndb.py +0 -0
  27. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/blocklist.py +0 -0
  28. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/charts.py +0 -0
  29. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/compat.py +0 -0
  30. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/completion.py +0 -0
  31. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/exporters.py +0 -0
  32. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/fetchcache.py +0 -0
  33. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/geo.py +0 -0
  34. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/geodb.py +0 -0
  35. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/handshake.py +0 -0
  36. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/history.py +0 -0
  37. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/judges.py +0 -0
  38. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/mcp_entry.py +0 -0
  39. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/mcp_server.py +0 -0
  40. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/netio.py +0 -0
  41. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/options.py +0 -0
  42. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/output.py +0 -0
  43. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/parsing.py +0 -0
  44. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/paths.py +0 -0
  45. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/pipeline.py +0 -0
  46. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/preferences.py +0 -0
  47. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/proxypages.py +0 -0
  48. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/report.py +0 -0
  49. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/runsteps.py +0 -0
  50. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/server/__init__.py +0 -0
  51. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/server/core.py +0 -0
  52. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/server/http.py +0 -0
  53. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/server/socks.py +0 -0
  54. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/server/status.py +0 -0
  55. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/server/upstream.py +0 -0
  56. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/site/apple-touch-icon.png +0 -0
  57. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/site/googleaac1161b7853c5b5.html +0 -0
  58. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/site/logo.png +0 -0
  59. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/site/og.png +0 -0
  60. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/sites.py +0 -0
  61. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/sources.json +0 -0
  62. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/sources.py +0 -0
  63. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/speed.py +0 -0
  64. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/targets.py +0 -0
  65. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/ui/__init__.py +0 -0
  66. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/ui/dashboard.py +0 -0
  67. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/ui/keys.py +0 -0
  68. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/ui/report.py +0 -0
  69. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/ui/serve.py +0 -0
  70. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/ui/widgets.py +0 -0
  71. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/proxyscraper/ui/wizard.py +0 -0
  72. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/pyproject.toml +0 -0
  73. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/setup.cfg +0 -0
  74. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_agent.py +0 -0
  75. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_api.py +0 -0
  76. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_app.py +0 -0
  77. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_asndb.py +0 -0
  78. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_auth.py +0 -0
  79. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_blocklist.py +0 -0
  80. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_charts.py +0 -0
  81. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_checker.py +0 -0
  82. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_compat.py +0 -0
  83. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_completion.py +0 -0
  84. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_discovery_growth.py +0 -0
  85. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_exporters.py +0 -0
  86. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_fetchcache.py +0 -0
  87. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_geodb.py +0 -0
  88. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_judges.py +0 -0
  89. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_learning.py +0 -0
  90. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_live_api.py +0 -0
  91. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_mcp_server.py +0 -0
  92. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_mine_sources.py +0 -0
  93. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_options.py +0 -0
  94. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_output_stdout.py +0 -0
  95. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_packaging.py +0 -0
  96. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_pages.py +0 -0
  97. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_parsing.py +0 -0
  98. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_parsing_fuzz.py +0 -0
  99. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_paths.py +0 -0
  100. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_pipeline.py +0 -0
  101. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_proxy_pages.py +0 -0
  102. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_proxy_sources.py +0 -0
  103. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_publish.py +0 -0
  104. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_report.py +0 -0
  105. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_robustness.py +0 -0
  106. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_rotator.py +0 -0
  107. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_serve_password.py +0 -0
  108. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_serve_refill.py +0 -0
  109. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_serve_v2.py +0 -0
  110. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_server.py +0 -0
  111. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_server_closed_writer.py +0 -0
  112. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_server_fixes.py +0 -0
  113. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_sites.py +0 -0
  114. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_sources_json.py +0 -0
  115. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_speed.py +0 -0
  116. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_tamper.py +0 -0
  117. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_targets.py +0 -0
  118. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_ui.py +0 -0
  119. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_uptime.py +0 -0
  120. {proxy_scraper_cli-1.17.0 → proxy_scraper_cli-1.19.0}/tests/test_wizard.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: proxy-scraper-cli
3
- Version: 1.17.0
3
+ Version: 1.19.0
4
4
  Summary: Finds free HTTP, SOCKS4 and SOCKS5 proxies that actually work: 700+ sources, real checks, honeypot filtering and a rotating local proxy server.
5
5
  Author: Maximilian Feix
6
6
  License-Expression: MIT
@@ -704,6 +704,7 @@ pip download requests # git, pip, npm & co. now go through the pool
704
704
  types: socks5
705
705
  https: true
706
706
  min-uptime: 90 # on the list for 90 %+ of the week
707
+ min-speed: 100 # optional: downloaded 100+ KB/s in the last check
707
708
  works-on: google # optional: google, reddit, amazon
708
709
  recheck: true # optional: check them again from the runner
709
710
  - run: curl -x "${{ steps.proxies.outputs.proxy }}" https://api.ipify.org
@@ -716,8 +717,12 @@ pip download requests # git, pip, npm & co. now go through the pool
716
717
  ```bash
717
718
  curl -x "$(proxy-scraper --pick --https-only --min-uptime 90)" https://api.ipify.org
718
719
  proxy-scraper --pick 10 --country DE --works-on google > de.txt
720
+ proxy-scraper --pick 5 --min-speed 200 # only ones that downloaded 200+ KB/s
719
721
  ```
720
722
 
723
+ "Fastest first" means the first answer plus the download speed measured in the last check – in a test with real
724
+ pages, the 25 fastest by download loaded four times as many pages as the 25 quickest to answer a tiny request.
725
+
721
726
  **Without installing anything** – straight from the live list
722
727
 
723
728
  ```bash
@@ -762,7 +767,7 @@ curl.exe -x (Get-Content "$run\all.txt" -TotalCount 1) http://api.ipify.org
762
767
  | `--discover` | search GitHub for new sources right now |
763
768
  | `--no-cache` | download every list again (unchanged ones are normally skipped via ETag) |
764
769
  | `--list-sources [N]` | show the source ranking (add `--json` for scripts: url, status, hit rate, checks, last change) |
765
- | `--pick [N]` | print N proxies (default 1) from the hourly checked list and exit – no scan, same filters, plus `--min-uptime PERCENT` and `--works-on google,reddit,…` |
770
+ | `--pick [N]` | print N proxies (default 1) from the hourly checked list and exit – no scan, same filters, plus `--min-uptime PERCENT`, `--min-speed KBPS` and `--works-on google,reddit,…` |
766
771
  | `--serve-host ADDR` | where the proxy server listens (default `127.0.0.1`; `0.0.0.0` for Docker, with a warning) |
767
772
  | `--serve-password SECRET` | clients must send this password in the proxy login; better set `PROXY_SCRAPER_SERVE_PASSWORD` |
768
773
  | `--rotate STRATEGY` · `--sticky SEC` | how the proxy server picks proxies, see [above](#proxy-server) |
@@ -663,6 +663,7 @@ pip download requests # git, pip, npm & co. now go through the pool
663
663
  types: socks5
664
664
  https: true
665
665
  min-uptime: 90 # on the list for 90 %+ of the week
666
+ min-speed: 100 # optional: downloaded 100+ KB/s in the last check
666
667
  works-on: google # optional: google, reddit, amazon
667
668
  recheck: true # optional: check them again from the runner
668
669
  - run: curl -x "${{ steps.proxies.outputs.proxy }}" https://api.ipify.org
@@ -675,8 +676,12 @@ pip download requests # git, pip, npm & co. now go through the pool
675
676
  ```bash
676
677
  curl -x "$(proxy-scraper --pick --https-only --min-uptime 90)" https://api.ipify.org
677
678
  proxy-scraper --pick 10 --country DE --works-on google > de.txt
679
+ proxy-scraper --pick 5 --min-speed 200 # only ones that downloaded 200+ KB/s
678
680
  ```
679
681
 
682
+ "Fastest first" means the first answer plus the download speed measured in the last check – in a test with real
683
+ pages, the 25 fastest by download loaded four times as many pages as the 25 quickest to answer a tiny request.
684
+
680
685
  **Without installing anything** – straight from the live list
681
686
 
682
687
  ```bash
@@ -721,7 +726,7 @@ curl.exe -x (Get-Content "$run\all.txt" -TotalCount 1) http://api.ipify.org
721
726
  | `--discover` | search GitHub for new sources right now |
722
727
  | `--no-cache` | download every list again (unchanged ones are normally skipped via ETag) |
723
728
  | `--list-sources [N]` | show the source ranking (add `--json` for scripts: url, status, hit rate, checks, last change) |
724
- | `--pick [N]` | print N proxies (default 1) from the hourly checked list and exit – no scan, same filters, plus `--min-uptime PERCENT` and `--works-on google,reddit,…` |
729
+ | `--pick [N]` | print N proxies (default 1) from the hourly checked list and exit – no scan, same filters, plus `--min-uptime PERCENT`, `--min-speed KBPS` and `--works-on google,reddit,…` |
725
730
  | `--serve-host ADDR` | where the proxy server listens (default `127.0.0.1`; `0.0.0.0` for Docker, with a warning) |
726
731
  | `--serve-password SECRET` | clients must send this password in the proxy login; better set `PROXY_SCRAPER_SERVE_PASSWORD` |
727
732
  | `--rotate STRATEGY` · `--sticky SEC` | how the proxy server picks proxies, see [above](#proxy-server) |
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: proxy-scraper-cli
3
- Version: 1.17.0
3
+ Version: 1.19.0
4
4
  Summary: Finds free HTTP, SOCKS4 and SOCKS5 proxies that actually work: 700+ sources, real checks, honeypot filtering and a rotating local proxy server.
5
5
  Author: Maximilian Feix
6
6
  License-Expression: MIT
@@ -704,6 +704,7 @@ pip download requests # git, pip, npm & co. now go through the pool
704
704
  types: socks5
705
705
  https: true
706
706
  min-uptime: 90 # on the list for 90 %+ of the week
707
+ min-speed: 100 # optional: downloaded 100+ KB/s in the last check
707
708
  works-on: google # optional: google, reddit, amazon
708
709
  recheck: true # optional: check them again from the runner
709
710
  - run: curl -x "${{ steps.proxies.outputs.proxy }}" https://api.ipify.org
@@ -716,8 +717,12 @@ pip download requests # git, pip, npm & co. now go through the pool
716
717
  ```bash
717
718
  curl -x "$(proxy-scraper --pick --https-only --min-uptime 90)" https://api.ipify.org
718
719
  proxy-scraper --pick 10 --country DE --works-on google > de.txt
720
+ proxy-scraper --pick 5 --min-speed 200 # only ones that downloaded 200+ KB/s
719
721
  ```
720
722
 
723
+ "Fastest first" means the first answer plus the download speed measured in the last check – in a test with real
724
+ pages, the 25 fastest by download loaded four times as many pages as the 25 quickest to answer a tiny request.
725
+
721
726
  **Without installing anything** – straight from the live list
722
727
 
723
728
  ```bash
@@ -762,7 +767,7 @@ curl.exe -x (Get-Content "$run\all.txt" -TotalCount 1) http://api.ipify.org
762
767
  | `--discover` | search GitHub for new sources right now |
763
768
  | `--no-cache` | download every list again (unchanged ones are normally skipped via ETag) |
764
769
  | `--list-sources [N]` | show the source ranking (add `--json` for scripts: url, status, hit rate, checks, last change) |
765
- | `--pick [N]` | print N proxies (default 1) from the hourly checked list and exit – no scan, same filters, plus `--min-uptime PERCENT` and `--works-on google,reddit,…` |
770
+ | `--pick [N]` | print N proxies (default 1) from the hourly checked list and exit – no scan, same filters, plus `--min-uptime PERCENT`, `--min-speed KBPS` and `--works-on google,reddit,…` |
766
771
  | `--serve-host ADDR` | where the proxy server listens (default `127.0.0.1`; `0.0.0.0` for Docker, with a warning) |
767
772
  | `--serve-password SECRET` | clients must send this password in the proxy login; better set `PROXY_SCRAPER_SERVE_PASSWORD` |
768
773
  | `--rotate STRATEGY` · `--sticky SEC` | how the proxy server picks proxies, see [above](#proxy-server) |
@@ -39,6 +39,7 @@ proxyscraper/pipeline.py
39
39
  proxyscraper/preferences.py
40
40
  proxyscraper/proxypages.py
41
41
  proxyscraper/publish.py
42
+ proxyscraper/ranking.py
42
43
  proxyscraper/report.py
43
44
  proxyscraper/runsteps.py
44
45
  proxyscraper/sites.py
@@ -109,6 +110,7 @@ tests/test_server_fixes.py
109
110
  tests/test_sites.py
110
111
  tests/test_sources_json.py
111
112
  tests/test_speed.py
113
+ tests/test_speed_ranking.py
112
114
  tests/test_tamper.py
113
115
  tests/test_targets.py
114
116
  tests/test_ui.py
@@ -1,7 +1,7 @@
1
1
  """proxy-scraper: collects public HTTP/SOCKS4/SOCKS5 proxies from hundreds of sources, checks them
2
2
  in parallel with its own protocol handshakes and learns which sources deliver good proxies."""
3
3
 
4
- __version__ = "1.17.0"
4
+ __version__ = "1.19.0"
5
5
 
6
6
 
7
7
  def __getattr__(name):
@@ -63,7 +63,7 @@ def main() -> int:
63
63
  filters = {"types": _list("PS_TYPES") or ["http", "socks4", "socks5"],
64
64
  "countries": os.environ.get("PS_COUNTRIES", "").strip(),
65
65
  "https": _flag("PS_HTTPS"), "min_uptime": _number("PS_MIN_UPTIME", 0),
66
- "works_on": _list("PS_WORKS_ON")}
66
+ "min_speed": _number("PS_MIN_SPEED", 0), "works_on": _list("PS_WORKS_ON")}
67
67
  # a recheck starts from all of them – the limit applies to what still works from here
68
68
  found = live_proxies(**filters, limit=0 if recheck else limit)
69
69
  except (InputError, ValueError) as e:
@@ -75,7 +75,9 @@ def main() -> int:
75
75
  urls = [p.url for p in found]
76
76
  if recheck and urls:
77
77
  print(f"Checking {len(urls)} proxies again from this runner …")
78
- urls = [r.url for r in sorted(check_proxies(urls, https=filters["https"]), key=lambda r: r.latency)]
78
+ # in the live list's order: it's ranked by page load, the recheck only knows the first answer
79
+ working = {r.url for r in check_proxies(urls, https=filters["https"])}
80
+ urls = [u for u in urls if u in working]
79
81
  if limit:
80
82
  urls = urls[:limit]
81
83
  # a file of its own per step: a job may use the action twice (socks5 in one step, http in the next)
@@ -34,6 +34,7 @@ from .netio import http_get
34
34
  from .pages import SITE_URL
35
35
  from .parsing import PROXY_TYPES, make_key
36
36
  from .publish import RAW_BASE
37
+ from .ranking import best_first
37
38
  from .server import ProxyPool, RotatingServer
38
39
  from .sites import SITES
39
40
 
@@ -180,11 +181,11 @@ def select(rows: Iterable[dict], protocol: str = "any", countries: Iterable[str]
180
181
  elite_only: bool = False, exclude_datacenter: bool = False, exclude_blocklisted: bool = False,
181
182
  stable_only: bool = False, max_latency_ms: int = 0, run_hours: int = 1, min_uptime: int = 0,
182
183
  works_on: Iterable[str] = (), min_speed_kbps: int = 0) -> List[dict]:
183
- """The rows that pass every filter, fastest first – the same filters as on the website."""
184
- return sorted(matching(rows, protocol, countries, https_only, elite_only, exclude_datacenter,
185
- exclude_blocklisted, stable_only, max_latency_ms, run_hours, min_uptime, works_on,
186
- min_speed_kbps),
187
- key=lambda r: r.get("latency") or 0)
184
+ """The rows that pass every filter, best first (answer plus download speed) – the same filters as on the
185
+ website."""
186
+ return best_first(matching(rows, protocol, countries, https_only, elite_only, exclude_datacenter,
187
+ exclude_blocklisted, stable_only, max_latency_ms, run_hours, min_uptime, works_on,
188
+ min_speed_kbps))
188
189
 
189
190
 
190
191
  def matching(rows: Iterable[dict], protocol: str = "any", countries: Iterable[str] = (), https_only: bool = False,
@@ -429,7 +430,8 @@ def _as_result(r: dict) -> Optional[CheckResult]:
429
430
  return CheckResult(make_key(r["ptype"], r["proxy"]), r["ptype"], r["proxy"], int(r.get("latency") or 0),
430
431
  str(r.get("exit_ip") or ""), https=r.get("https"), anonymity=r.get("anonymity") or "",
431
432
  country=r.get("country") or "", asn=int(r.get("asn") or 0), org=r.get("org") or "",
432
- hosting=r.get("hosting"), blocklisted=r.get("blocklisted"))
433
+ hosting=r.get("hosting"), blocklisted=r.get("blocklisted"),
434
+ speed_kbps=r["speed_kbps"] if type(r.get("speed_kbps")) is int else None)
433
435
  except (KeyError, TypeError, ValueError):
434
436
  return None
435
437
 
@@ -204,8 +204,9 @@ async def live_proxies_async(*, types: Iterable[str] = PROXY_TYPES, countries: I
204
204
  anonymity: str = "", max_latency: int = 0, no_datacenter: bool = False,
205
205
  no_blocklisted: bool = False, min_uptime: int = 0, works_on: Iterable[str] = (),
206
206
  min_speed: int = 0, limit: int = 0) -> List[LiveProxy]:
207
- """The proxies from the hourly list that pass the filters, fastest first. Nothing is checked here: they
208
- worked from GitHub's servers in the last run (at most an hour ago). find_proxies checks from your network.
207
+ """The proxies from the hourly list that pass the filters, fastest first – by first answer plus measured
208
+ download speed. Nothing is checked here: they worked from GitHub's servers in the last run (at most an hour
209
+ ago). find_proxies checks from your network.
209
210
 
210
211
  Same filters as find_proxies, plus
211
212
  min_uptime only proxies listed in at least this share (percent) of the week's runs, e.g. 90
@@ -215,6 +216,7 @@ async def live_proxies_async(*, types: Iterable[str] = PROXY_TYPES, countries: I
215
216
  limit at most this many (0 = all)
216
217
  """
217
218
  from .agent import AgentError, LiveSource
219
+ from .ranking import page_ms, typical_speed
218
220
  from .sites import SITE
219
221
 
220
222
  types = _types(types)
@@ -237,9 +239,11 @@ async def live_proxies_async(*, types: Iterable[str] = PROXY_TYPES, countries: I
237
239
  data = await LiveSource(fetch=_live_fetch).get()
238
240
  except AgentError as e:
239
241
  raise ConnectionError(str(e)) from None
240
- found = sorted((_live_proxy(r, data.run_hours) for r in data.rows
241
- if r.get("ptype") in types and isinstance(r.get("proxy"), str)),
242
- key=lambda p: p.latency)
242
+ found = [_live_proxy(r, data.run_hours) for r in data.rows
243
+ if r.get("ptype") in types and isinstance(r.get("proxy"), str)]
244
+ # fastest first – by how quickly a page comes through when the list has download speeds (#186)
245
+ typical = typical_speed(p.speed_kbps for p in found)
246
+ found.sort(key=lambda p: page_ms(p.latency, p.speed_kbps, p.https, typical))
243
247
  found = [p for p in found if opts.filters.accepts(p) and (not min_uptime or (p.uptime_7d or 0) >= min_uptime)
244
248
  and all(p.sites.get(s) for s in works_on) and (not min_speed or (p.speed_kbps or 0) >= min_speed)]
245
249
  return found[:limit] if limit else found
@@ -93,6 +93,7 @@ class CheckResult:
93
93
  org: str = ""
94
94
  hosting: Optional[bool] = None # exit probably in a datacenter? None = unknown
95
95
  blocklisted: Optional[bool] = None # exit IP on the SpamCop blocklist? None = unknown
96
+ speed_kbps: Optional[int] = None # download speed from the live list (KiB/s), None = not measured
96
97
 
97
98
  @property
98
99
  def url(self) -> str:
@@ -71,7 +71,8 @@ def pick(args) -> int:
71
71
  found = live_proxies(types=args.types, countries=args.country or "", https=args.https_only,
72
72
  anonymity=args.anonymity or "", max_latency=args.max_latency,
73
73
  no_datacenter=args.no_datacenter, no_blocklisted=args.no_blocklisted,
74
- min_uptime=args.min_uptime, works_on=args.works_on, limit=args.pick)
74
+ min_uptime=args.min_uptime, works_on=args.works_on, min_speed=args.min_speed,
75
+ limit=args.pick)
75
76
  except (ConnectionError, ValueError) as e:
76
77
  print(f"proxy-scraper: {e}", file=sys.stderr)
77
78
  return 1
@@ -204,6 +205,8 @@ def parse_args(argv: Optional[List[str]] = None) -> argparse.Namespace:
204
205
  "one URL per line, and exit – e.g. curl -x \"$(proxy-scraper --pick --https-only)\" …")
205
206
  live.add_argument("--min-uptime", type=percent, default=0, metavar="PERCENT",
206
207
  help="with --pick: only proxies on the list in at least this share of the week's checks")
208
+ live.add_argument("--min-speed", type=positive_int, default=0, metavar="KBPS",
209
+ help="with --pick: only proxies that downloaded at least this many KB/s in the last check")
207
210
  live.add_argument("--works-on", type=site_list, default=[], metavar="SITES",
208
211
  help=f"with --pick: only proxies that got through to these sites in the last check "
209
212
  f"({', '.join(s.name for s in SITES)})")
@@ -251,8 +254,8 @@ def parse_args(argv: Optional[List[str]] = None) -> argparse.Namespace:
251
254
  args = p.parse_args(argv)
252
255
  if args.json and args.list_sources is None:
253
256
  p.error("--json only works together with --list-sources")
254
- if (args.min_uptime or args.works_on) and args.pick is None:
255
- p.error("--min-uptime and --works-on only work together with --pick")
257
+ if (args.min_uptime or args.works_on or args.min_speed) and args.pick is None:
258
+ p.error("--min-uptime, --min-speed and --works-on only work together with --pick")
256
259
  if args.pick is not None: # --pick exits right away: options for a scan or the server would be silently ignored
257
260
  scan_only = [flag for dest, flag in (("target", "--target"), ("serve", "--serve"), ("recheck", "--recheck"),
258
261
  ("want", "--want"), ("output", "-o/--output"), ("export", "--export"))
@@ -14,6 +14,8 @@ from html import escape
14
14
  from pathlib import Path
15
15
  from typing import Callable, Dict, List, Sequence, Tuple
16
16
 
17
+ from .ranking import best_first
18
+
17
19
  SITE_URL = "https://maximilianfeix.github.io/proxy-scraper/"
18
20
  REPO_URL = "https://github.com/maximilianfeix/proxy-scraper"
19
21
  ROWS_PER_PAGE = 200
@@ -203,8 +205,8 @@ def _render(path: str, title: str, what: str, rows: List[dict], updated: datetim
203
205
  f"<td>{'yes' if r.get('https') else 'no'}</td><td>{escape(through)}</td>"
204
206
  f"<td>{escape((r.get('org') or '–')[:40])}</td></tr>")
205
207
  body_rows = "\n".join(cells(r) for r in rows[:ROWS_PER_PAGE])
206
- table = (f"<div class=\"table\"><table><caption>The {min(total, ROWS_PER_PAGE):,} fastest, as ip:port. "
207
- f"The download has all {total:,} as type://ip:port.</caption>"
208
+ table = (f"<div class=\"table\"><table><caption>The {min(total, ROWS_PER_PAGE):,} fastest to load a page, "
209
+ f"as ip:port. The download has all {total:,} as type://ip:port.</caption>"
208
210
  "<thead><tr><th scope=\"col\">Proxy</th><th scope=\"col\">Type</th><th scope=\"col\">Country</th>"
209
211
  "<th scope=\"col\">Latency</th><th scope=\"col\">Speed</th><th scope=\"col\">Uptime</th>"
210
212
  "<th scope=\"col\">HTTPS</th><th scope=\"col\">Gets through</th>"
@@ -307,7 +309,7 @@ def _nav(specs, counts: Dict[str, int], current: str, root: str) -> str:
307
309
  def write_pages(rows: List[dict], out: Path, updated: datetime, extra: Sequence[str] = ()) -> List[str]:
308
310
  """Writes every page with its proxies.txt and the sitemap (plus the `extra` paths, e.g. the proxy pages)
309
311
  -> the paths listed in the sitemap."""
310
- rows = sorted(rows, key=lambda r: r["latency"])
312
+ rows = best_first(rows)
311
313
  specs = page_specs()
312
314
  selected = {p: [r for r in rows if keep(r)] for p, _, _, keep in specs}
313
315
  counts = {p: len(v) for p, v in selected.items()}
@@ -25,6 +25,7 @@ from .charts import THEMES, countries_svg, trend_svg
25
25
  from .pages import write_pages
26
26
  from .parsing import PROXY_TYPES
27
27
  from .proxypages import write_proxy_pages
28
+ from .ranking import best_first
28
29
  from .report import weekly_facts, write_report
29
30
  from .sites import SITES
30
31
 
@@ -43,7 +44,7 @@ def is_public(row: dict) -> bool:
43
44
 
44
45
  def load_rows(run_dir: Path) -> List[dict]:
45
46
  rows = json.loads((run_dir / "proxies.json").read_text(encoding="utf-8"))
46
- return sorted((r for r in rows if is_public(r)), key=lambda r: r["latency"])
47
+ return best_first(r for r in rows if is_public(r))
47
48
 
48
49
 
49
50
  def num(n: int) -> str:
@@ -116,7 +117,8 @@ def readme(stats: dict, counts: Dict[str, int]) -> str:
116
117
  return f"""# Live proxy list
117
118
 
118
119
  Generated automatically by [proxy-scraper](https://github.com/maximilianfeix/proxy-scraper) with GitHub Actions.
119
- Every proxy here really worked in the last run – sorted by latency, fastest first.
120
+ Every proxy here really worked in the last run – fastest first, by first answer plus the download speed measured
121
+ right after the run.
120
122
  Browse and filter it on the [website](https://maximilianfeix.github.io/proxy-scraper/).
121
123
 
122
124
  **Updated:** {updated} · **{num(stats["total"])} proxies** · median latency {num(stats["median_latency"])} ms
@@ -280,10 +282,10 @@ def publish(run_dir: Path, out: Path, minimum: int = 20, now: Optional[datetime]
280
282
  base = list(reader.fieldnames or ["proxy"])
281
283
  writer = csv.DictWriter(dst, fieldnames=[*base, *(k for k in extra if k not in base)])
282
284
  writer.writeheader()
283
- by_url = {r["url"]: r for r in rows}
284
- for r in reader:
285
- if is_public(r):
286
- listed_row = by_url.get(r.get("url", ""), {})
285
+ csv_rows = {r.get("url", ""): r for r in reader if is_public(r)}
286
+ for listed_row in rows: # in the order of proxies.json: best first
287
+ r = csv_rows.get(listed_row.get("url", ""))
288
+ if r is not None:
287
289
  works = " ".join(name for name, ok in (listed_row.get("sites") or {}).items() if ok)
288
290
  writer.writerow({**r, **{k: listed_row.get(k, "") for k in extra}, "works_with": works})
289
291
  stats = stats_for(rows, now)
@@ -0,0 +1,44 @@
1
+ """Which proxy is "fastest": how quickly a page comes through, not just the first answer (#186).
2
+
3
+ A quick answer to one tiny request says little about loading a page – in a test on the live list, the 25 HTTPS
4
+ proxies quickest to answer loaded 4 of 50 real pages, the first 25 ranked by answer plus the download speed of the
5
+ hourly speed step 26 of 50. Everything that orders proxies of the live list uses this: the published lists, the
6
+ pages, --pick, live_proxies, the rotating pool.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import statistics
12
+ from typing import Iterable, List, Optional
13
+
14
+ PAGE_KB = 100 # roughly one page – the download the speed step measures
15
+ UNMEASURED_KBPS = 20 # tried in the speed step, no download got through: counted as slow (it passed the checks)
16
+
17
+
18
+ def page_ms(latency: float, speed_kbps: Optional[int], https: Optional[bool], typical_kbps: Optional[float]) -> float:
19
+ """Roughly how long a page takes through a proxy: the first answer plus the download.
20
+
21
+ typical_kbps is the median measured speed of the set, None when it has no speeds at all (an own scan) – then
22
+ latency decides alone. The speed step only tries HTTPS-capable proxies: one of those without a speed didn't
23
+ get the download through, the others were never tried and count as typical."""
24
+ if not typical_kbps:
25
+ return latency
26
+ kbps = speed_kbps or (UNMEASURED_KBPS if https else typical_kbps)
27
+ return latency + PAGE_KB * 1000 / kbps
28
+
29
+
30
+ def typical_speed(speeds: Iterable[Optional[int]]) -> Optional[float]:
31
+ measured = [s for s in speeds if s]
32
+ return statistics.median(measured) if measured else None
33
+
34
+
35
+ def best_first(rows: Iterable[dict]) -> List[dict]:
36
+ """Rows of a run (dicts as in proxies.json), the fastest to load a page first."""
37
+ rows = list(rows)
38
+ typical = typical_speed(_speed(r) for r in rows)
39
+ return sorted(rows, key=lambda r: page_ms(r["latency"], _speed(r), r.get("https") is True, typical))
40
+
41
+
42
+ def _speed(row: dict) -> Optional[int]:
43
+ value = row.get("speed_kbps")
44
+ return value if type(value) is int and value > 0 else None
@@ -4,6 +4,9 @@ Selection per connection in three steps:
4
4
  1. filters from the request (Selection): country, type – via the user name, e.g. "country-de-type-socks5"
5
5
  2. sticky: the same session (or with --sticky the same target site) keeps the same proxy for a while
6
6
  3. strategy for everything else: weighted (default), random, round-robin, fastest
7
+
8
+ "Fast" means how quickly a page comes through, not just the first answer: when the proxies come from the live list,
9
+ which measures a download per proxy every hour, that download counts too (#186).
7
10
  """
8
11
 
9
12
  from __future__ import annotations
@@ -14,6 +17,7 @@ import time
14
17
  from dataclasses import dataclass
15
18
  from typing import Callable, Dict, List, Optional, Set, Tuple
16
19
 
20
+ from .. import ranking
17
21
  from ..checker import CheckResult
18
22
 
19
23
  DISABLE_AFTER = 3 # this many failures in a row -> out of the rotation
@@ -22,6 +26,15 @@ SESSION_SECONDS = 600 # how long a session (session-…) keeps its proxy w
22
26
  _TOKEN_RE = re.compile(r"(country|type|session)[-_]([A-Za-z0-9]+)")
23
27
 
24
28
 
29
+ def page_ms(result, typical_kbps: Optional[float]) -> float:
30
+ """ranking.page_ms for a CheckResult (or anything with latency, speed_kbps and https)."""
31
+ return ranking.page_ms(result.latency, result.speed_kbps, result.https, typical_kbps)
32
+
33
+
34
+ def typical_speed(results) -> Optional[float]:
35
+ return ranking.typical_speed(r.speed_kbps for r in results)
36
+
37
+
25
38
  @dataclass(frozen=True)
26
39
  class Selection:
27
40
  """The client's wishes for this connection – they come from the user name of the proxy login."""
@@ -57,12 +70,17 @@ class PoolEntry:
57
70
  fail_streak: int = 0
58
71
  active: int = 0
59
72
  disabled: bool = False
73
+ typical_kbps: Optional[float] = None # set by the pool: median measured speed of its proxies
74
+
75
+ @property
76
+ def cost(self) -> float:
77
+ return page_ms(self.result, self.typical_kbps)
60
78
 
61
79
  @property
62
80
  def weight(self) -> float:
63
81
  # prefer fast and proven ones, but give everyone a chance
64
82
  reliability = (self.ok + 1) / (self.ok + self.fail + 2)
65
- return reliability / (self.result.latency + 300)
83
+ return reliability / (self.cost + 300)
66
84
 
67
85
 
68
86
  class ProxyPool:
@@ -71,7 +89,8 @@ class ProxyPool:
71
89
  clock: Callable[[], float] = time.monotonic, strict_tls: bool = False):
72
90
  if strategy not in STRATEGIES:
73
91
  raise ValueError(f"unknown strategy {strategy!r} (possible: {', '.join(STRATEGIES)})")
74
- self.entries = [PoolEntry(r) for r in sorted(results, key=lambda r: r.latency)]
92
+ typical = typical_speed(results)
93
+ self.entries = sorted((PoolEntry(r, typical_kbps=typical) for r in results), key=lambda e: e.cost)
75
94
  self.rng = rng or random.Random()
76
95
  self.strategy = strategy
77
96
  self.sticky_seconds = sticky_seconds
@@ -135,8 +154,8 @@ class ProxyPool:
135
154
  # the fastest free one; if all are busy, the least busy one (then the faster one)
136
155
  idle = [e for e in candidates if not e.active]
137
156
  if idle:
138
- return min(idle, key=lambda e: (e.result.latency, -e.weight))
139
- return min(candidates, key=lambda e: (e.active, e.result.latency))
157
+ return min(idle, key=lambda e: (e.cost, -e.weight))
158
+ return min(candidates, key=lambda e: (e.active, e.cost))
140
159
  if self.strategy == "round-robin":
141
160
  ordered = sorted(candidates, key=lambda e: e.result.key)
142
161
  entry = ordered[self._next % len(ordered)]
@@ -186,7 +205,10 @@ class ProxyPool:
186
205
  for r in fresh.values():
187
206
  kept.append(PoolEntry(r))
188
207
  added += 1
189
- self.entries = sorted(kept, key=lambda e: e.result.latency)
208
+ typical = typical_speed([e.result for e in kept])
209
+ for entry in kept:
210
+ entry.typical_kbps = typical
211
+ self.entries = sorted(kept, key=lambda e: e.cost)
190
212
  return added
191
213
 
192
214
  def revive(self, entry: PoolEntry) -> None:
@@ -597,7 +597,7 @@
597
597
  <section class="block wrap" id="list" aria-labelledby="list-title">
598
598
  <div class="head-row">
599
599
  <h2 class="h2" id="list-title">Pick your proxies</h2>
600
- <p class="intro-text">Filter, sort, then copy or download exactly the ones you need. Click any address to copy it.</p>
600
+ <p class="intro-text">Best first: the ones that answer quickly and download fast. Filter, sort, then copy or download exactly the ones you need. Click any address to copy it.</p>
601
601
  </div>
602
602
  <div class="filters" role="group" aria-label="Filters">
603
603
  <button class="chip" type="button" data-type="http" aria-pressed="true"><span class="dot http"></span>HTTP</button>
@@ -623,7 +623,7 @@
623
623
  <th scope="col" data-key="ptype"><button class="sort" type="button" aria-label="Type"><span class="name">Type</span></button></th>
624
624
  <th scope="col" data-key="proxy"><button class="sort" type="button">Proxy</button></th>
625
625
  <th scope="col" data-key="country"><button class="sort" type="button">Country</button></th>
626
- <th scope="col" data-key="latency" aria-sort="ascending"><button class="sort" type="button">Latency</button></th>
626
+ <th scope="col" data-key="latency"><button class="sort" type="button">Latency</button></th>
627
627
  <th scope="col" data-key="speed_kbps" class="hide-sm"><button class="sort" type="button" title="Download speed in the last run – 100 KB through the proxy">Speed</button></th>
628
628
  <th scope="col" data-key="https" class="hide-sm"><button class="sort" type="button">HTTPS</button></th>
629
629
  <th scope="col" data-key="uptime_7d" class="hide-sm"><button class="sort" type="button" title="Share of this week's runs it was on the list">Uptime</button></th>
@@ -637,6 +637,7 @@
637
637
  <div class="list-foot">
638
638
  <span class="count" id="count" aria-live="polite"></span>
639
639
  <div class="actions">
640
+ <button class="btn small" id="best" type="button" hidden title="The ones that answer quickly and download fast">Best first</button>
640
641
  <button class="btn small" id="more" type="button" hidden>Show more</button>
641
642
  <button class="btn small" id="share" type="button" title="The filters are in the address, so the link opens this exact view">Share view</button>
642
643
  <button class="btn small" id="copy-all" type="button">Copy filtered</button>
@@ -871,7 +872,7 @@ proxy-scraper --want 50 --https-only</pre><button class="icon-btn" type="button"
871
872
  const speed = (k) => !k ? '<span class="quiet">–</span>'
872
873
  : `<span class="${k >= 500 ? "fast" : k >= 100 ? "mid" : "slow"}">${k >= 1024 ? (k / 1024).toFixed(1) + " MB/s" : fmt(k) + " KB/s"}</span>`;
873
874
  const latency = (ms) => `<span class="${ms < 1000 ? "fast" : ms < 3000 ? "mid" : "slow"}">${fmt(ms)} ms</span>`;
874
- const state = { rows: [], shown: PAGE, sort: "latency", dir: 1, types: new Set(["http", "socks4", "socks5"]),
875
+ const state = { rows: [], shown: PAGE, sort: "rank", dir: 1, types: new Set(["http", "socks4", "socks5"]),
875
876
  https: false, elite: false, noDc: false, noBl: false, stable: false, country: "", site: "", maxLat: 8000, q: "" };
876
877
 
877
878
  // Theme
@@ -1037,6 +1038,7 @@ proxy-scraper --want 50 --https-only</pre><button class="icon-btn" type="button"
1037
1038
  || '<tr><td colspan="9" class="empty">No proxy matches these filters. Try a higher latency limit or fewer filters.</td></tr>';
1038
1039
  $("#count").textContent = rows.length ? `Showing ${fmt(Math.min(state.shown, rows.length))} of ${fmt(rows.length)} matching proxies` : "";
1039
1040
  $("#more").hidden = rows.length <= state.shown;
1041
+ $("#best").hidden = state.sort === "rank";
1040
1042
  saveView();
1041
1043
  $$("th[data-key]").forEach(th => th.dataset.key === state.sort ? th.setAttribute("aria-sort", state.dir > 0 ? "ascending" : "descending") : th.removeAttribute("aria-sort"));
1042
1044
  }
@@ -1052,7 +1054,7 @@ proxy-scraper --want 50 --https-only</pre><button class="icon-btn" type="button"
1052
1054
  if (state.site) q.set("site", state.site);
1053
1055
  if (state.maxLat < 8000) q.set("latency", state.maxLat);
1054
1056
  if (state.q.trim()) q.set("q", state.q.trim());
1055
- if (state.sort !== "latency" || state.dir !== 1) q.set("sort", (state.dir < 0 ? "-" : "") + state.sort);
1057
+ if (state.sort !== "rank") q.set("sort", (state.dir < 0 ? "-" : "") + state.sort);
1056
1058
  return location.pathname + (q.toString() ? `?${q}` : "") + location.hash;
1057
1059
  }
1058
1060
  // debounced: browsers limit replaceState (Safari throws after ~100 calls in 30 s, e.g. while dragging the slider)
@@ -1117,6 +1119,7 @@ proxy-scraper --want 50 --https-only</pre><button class="icon-btn" type="button"
1117
1119
  $("#f-lat").oninput = (e) => { state.maxLat = +e.target.value; $("#f-lat-v").textContent = state.maxLat >= 8000 ? "any" : `${fmt(state.maxLat)} ms`; refresh(); };
1118
1120
  $("#f-q").oninput = (e) => { state.q = e.target.value; refresh(); };
1119
1121
  $("#more").onclick = () => { state.shown += PAGE * 4; render(); };
1122
+ $("#best").onclick = () => { state.sort = "rank"; state.dir = 1; morph(render); };
1120
1123
  $$("th[data-key]").forEach(th => {
1121
1124
  th.querySelector(".sort").onclick = () => { const k = th.dataset.key; state.dir = state.sort === k ? -state.dir : 1; state.sort = k; morph(render); };
1122
1125
  });
@@ -1353,6 +1356,7 @@ proxy-scraper --want 50 --https-only</pre><button class="icon-btn" type="button"
1353
1356
 
1354
1357
  let started = false;
1355
1358
  function apply(rows, st, history) {
1359
+ rows.forEach((r, i) => { r.rank = i; }); // proxies.json comes best first: first answer plus download speed
1356
1360
  state.rows = rows;
1357
1361
  shownRun = st.updated;
1358
1362
  RUN_HOURS = st.run_hours || 6; // lists from before run_hours existed ran every 6 hours
@@ -11,7 +11,7 @@ def fake(n, **extra):
11
11
  for i in range(n)]
12
12
 
13
13
 
14
- def run(monkeypatch, tmp_path, env, found=3, rechecked=None):
14
+ def run(monkeypatch, tmp_path, env, found=3, rechecked=None, recheck=None):
15
15
  calls = {}
16
16
 
17
17
  def live(**kwargs):
@@ -20,7 +20,7 @@ def run(monkeypatch, tmp_path, env, found=3, rechecked=None):
20
20
 
21
21
  def check(urls, **kwargs):
22
22
  calls["check"] = list(urls)
23
- return fake(found)[:rechecked]
23
+ return recheck(found) if recheck else fake(found)[:rechecked]
24
24
  monkeypatch.setattr(action, "live_proxies", live)
25
25
  monkeypatch.setattr(action, "check_proxies", check)
26
26
  out = tmp_path / "out.txt"
@@ -36,10 +36,10 @@ def run(monkeypatch, tmp_path, env, found=3, rechecked=None):
36
36
  def test_filters_reach_live_proxies_and_outputs_are_set(monkeypatch, tmp_path):
37
37
  code, out, calls = run(monkeypatch, tmp_path, {
38
38
  "PS_TYPES": "socks5, http", "PS_COUNTRIES": "de,nl", "PS_HTTPS": "true", "PS_MIN_UPTIME": "90",
39
- "PS_WORKS_ON": "google", "PS_LIMIT": "2"})
39
+ "PS_MIN_SPEED": "100", "PS_WORKS_ON": "google", "PS_LIMIT": "2"})
40
40
  assert code == 0
41
41
  assert calls["live"] == {"types": ["socks5", "http"], "countries": "de,nl", "https": True, "min_uptime": 90,
42
- "works_on": ["google"], "limit": 2}
42
+ "min_speed": 100, "works_on": ["google"], "limit": 2}
43
43
  assert out["proxy"] == "socks5://1.1.1.0:1080" and out["count"] == "2" # limit
44
44
  file = out["file"]
45
45
  assert file.startswith(str(tmp_path)) and Path(file).read_text().splitlines()[0] == "socks5://1.1.1.0:1080"
@@ -67,3 +67,12 @@ def test_nothing_found_fails_the_step_unless_allowed(monkeypatch, tmp_path, caps
67
67
  def test_bad_inputs_are_explained(monkeypatch, tmp_path, capsys):
68
68
  code, _, _ = run(monkeypatch, tmp_path, {"PS_LIMIT": "lots"})
69
69
  assert code == 1 and "limit" in capsys.readouterr().out
70
+
71
+
72
+
73
+ def test_a_recheck_keeps_the_live_lists_order(monkeypatch, tmp_path):
74
+ # the live list comes ranked by page load; the recheck's latencies say nothing about downloads
75
+ def slower_first(n): # from the runner, the list's first proxy happens to answer slowest
76
+ return [CheckResult(r.key, r.ptype, r.proxy, 500 - r.latency, r.exit_ip, True) for r in fake(n)]
77
+ _, out, _ = run(monkeypatch, tmp_path, {"PS_RECHECK": "true"}, recheck=slower_first)
78
+ assert out["proxy"] == "socks5://1.1.1.0:1080"
@@ -42,3 +42,10 @@ def test_options_for_a_scan_are_an_error_not_ignored(extra, capsys):
42
42
  with pytest.raises(SystemExit):
43
43
  cli.run(["--pick", *extra])
44
44
  assert "--pick" in capsys.readouterr().err
45
+
46
+
47
+ def test_min_speed_keeps_only_proxies_that_downloaded_that_fast(monkeypatch, capsys):
48
+ rows = [dict(ROWS[0], speed_kbps=300), dict(ROWS[2], speed_kbps=40), ROWS[1]]
49
+ monkeypatch.setattr(api, "_live_fetch", fetch_from({"proxies.json": rows, "stats.json": STATS}))
50
+ assert cli.run(["--pick", "5", "--min-speed", "100"]) == 0
51
+ assert capsys.readouterr().out == "socks5://1.1.1.1:1080\n"
@@ -0,0 +1,108 @@
1
+ """Download speed in the choice of proxy (#186): a quick answer to one tiny request says little about loading a
2
+ page – in a test on the live list, the 25 proxies with the best latency loaded 8 of 50 pages, the 25 that downloaded
3
+ fastest in the last run 33 of 50."""
4
+
5
+ import random
6
+
7
+ from proxyscraper import api, live_proxies
8
+ from proxyscraper.agent import _as_result
9
+ from proxyscraper.checker import CheckResult
10
+ from proxyscraper.server import ProxyPool
11
+ from proxyscraper.server.pool import page_ms
12
+
13
+ from .test_live_api import ROWS, STATS, fetch_from
14
+
15
+
16
+ def result(n, latency, speed=None, https=True):
17
+ proxy = f"10.0.0.{n}:80"
18
+ return CheckResult(f"http {proxy}", "http", proxy, latency, "9.9.9.9", https=https, speed_kbps=speed)
19
+
20
+
21
+ def test_a_proxy_that_downloads_fast_beats_one_that_only_answers_fast():
22
+ quick_ping, fast_download = result(1, 100), result(2, 400, speed=500)
23
+ assert page_ms(fast_download, typical_kbps=100) < page_ms(quick_ping, typical_kbps=100)
24
+ pool = ProxyPool([quick_ping, fast_download], strategy="fastest")
25
+ assert pool.pick(set()).result is fast_download
26
+
27
+
28
+ def test_the_weighted_choice_leans_to_the_fast_downloader():
29
+ pool = ProxyPool([result(1, 100), result(2, 400, speed=500)], rng=random.Random(1))
30
+ picks = [pool.pick(set()).result.proxy for _ in range(1000)]
31
+ assert picks.count("10.0.0.2:80") > 700
32
+
33
+
34
+ def test_without_any_speed_data_latency_decides_as_before():
35
+ pool = ProxyPool([result(1, 400), result(2, 100)], strategy="fastest")
36
+ assert pool.pick(set()).result.latency == 100
37
+
38
+
39
+ def test_the_live_list_brings_its_speed_into_the_pool():
40
+ row = {"ptype": "http", "proxy": "1.2.3.4:80", "latency": 100, "https": True, "speed_kbps": 250}
41
+ assert _as_result(row).speed_kbps == 250
42
+ assert _as_result({**row, "speed_kbps": "fast"}).speed_kbps is None
43
+
44
+
45
+ def test_live_proxies_put_the_measured_fast_ones_first(monkeypatch):
46
+ rows = [dict(r) for r in ROWS]
47
+ rows[0]["speed_kbps"] = 400 # socks5, latency 300 – the slowest to answer, the only one that downloaded
48
+ monkeypatch.setattr(api, "_live_fetch", fetch_from({"proxies.json": rows, "stats.json": STATS}))
49
+ # the socks4 one answers faster but got no download through in the speed step
50
+ assert [p.url for p in live_proxies(https=True)] == ["socks5://1.1.1.1:1080", "socks4://3.3.3.3:4145"]
51
+
52
+
53
+ def test_proxies_the_speed_step_never_tried_count_as_typical_not_slow():
54
+ # it only measures HTTPS-capable ones – a plain-HTTP-only proxy wasn't slow, it just wasn't measured
55
+ plain_only, measured = result(1, 50, https=False), result(2, 900, speed=100)
56
+ pool = ProxyPool([plain_only, measured], strategy="fastest")
57
+ assert pool.pick(set()).result is plain_only
58
+ assert pool.pick(set(), tls=True).result is measured
59
+
60
+
61
+ def published(n, latency, speed=None, https=True, ptype="http"):
62
+ row = {"proxy": f"10.0.0.{n}:80", "ptype": ptype, "url": f"{ptype}://10.0.0.{n}:80", "latency": latency,
63
+ "https": https, "country": "DE", "exit_ip": f"10.0.0.{n}", "anonymity": "elite"}
64
+ return {**row, "speed_kbps": speed} if speed else row
65
+
66
+
67
+ def test_the_published_lists_start_with_the_ones_that_load_pages_fastest(tmp_path):
68
+ import json
69
+
70
+ from proxyscraper import publish
71
+
72
+ (tmp_path / "proxies.json").write_text(json.dumps([published(1, 100), published(2, 400, speed=500)]))
73
+ assert [r["proxy"] for r in publish.load_rows(tmp_path)] == ["10.0.0.2:80", "10.0.0.1:80"]
74
+
75
+
76
+ def test_landing_pages_list_the_best_first(tmp_path):
77
+ from datetime import datetime, timezone
78
+
79
+ from proxyscraper import pages
80
+
81
+ pages.write_pages([published(1, 100), published(2, 400, speed=500)], tmp_path, datetime.now(timezone.utc))
82
+ assert (tmp_path / "country" / "de" / "proxies.txt").read_text().splitlines()[0] == "http://10.0.0.2:80"
83
+
84
+
85
+ def test_the_csv_comes_in_the_same_order_as_the_json(tmp_path):
86
+ import csv
87
+ import json
88
+
89
+ from proxyscraper import publish
90
+ from proxyscraper.output import ResultWriter
91
+
92
+ results = [CheckResult(f"http 1.1.1.{i}:80", "http", f"1.1.1.{i}:80", 100 * (i + 1), "9.9.9.9", True, "elite", "DE")
93
+ for i in range(3)]
94
+ ResultWriter(run_dir=tmp_path / "run").finalize(results)
95
+ rows = json.loads((tmp_path / "run" / "proxies.json").read_text())
96
+ rows[2]["speed_kbps"] = 900 # the slowest to answer downloads fastest
97
+ (tmp_path / "run" / "proxies.json").write_text(json.dumps(rows))
98
+ publish.publish(tmp_path / "run", tmp_path / "out", minimum=1)
99
+ order = [r["proxy"] for r in json.loads((tmp_path / "out" / "proxies.json").read_text())]
100
+ with (tmp_path / "out" / "proxies.csv").open(newline="") as fh:
101
+ assert [r["proxy"] for r in csv.DictReader(fh)] == order and order[0] == "1.1.1.2:80"
102
+
103
+
104
+ def test_the_mcp_tools_list_best_first_too():
105
+ from proxyscraper.agent import select
106
+
107
+ rows = [published(1, 100), published(2, 400, speed=500)]
108
+ assert [r["proxy"] for r in select(rows)] == ["10.0.0.2:80", "10.0.0.1:80"]