推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
cy1027
V2EX  ›  Python

Python 代理问题, requests 自带的 proxies 参数会导致请求失败

  •  
  •   cy1027 · Aug 2, 2022 · 3445 views
    This topic created in 1558 days ago, the information mentioned may be changed or developed.

    一个请求通过 fiddler 走了代理,能请求,但是另一个用 requests 自带的配置走代理请求,就失败 有大佬知能给指点指点不?

    9 replies  •  2022-08-03 07:40:20 +08:00
    cy1027
    cy1027
    OP
    Aug 2, 2022
    1
    我两次请求用了同样的其它参数,唯一不同的就是一个请求用 requests 自带的 proxies 添加了代理,另外一个用 fiddler 的 gateway 功能走了代理,两种方式走的是同一个代理
    45HXlKzal6W56zUJ
    45HXlKzal6W56zUJ
    Aug 2, 2022
    2
    你代码写错了
    tanjnr
    tanjnr
    Aug 2, 2022 via iPhone
    3
    你代码写错了+1
    hlpureboy
    hlpureboy
    Aug 2, 2022
    4
    估计代码写错惹
    whattime
    whattime
    Aug 2, 2022
    5
    http_proxy = "http://127.0.0.1:1081"
    https_proxy = "http://127.0.0.1:1081"
    ftp_proxy = "ftp://127.0.0.1:1081"

    proxyDict = {
    "http" : http_proxy,
    "https" : https_proxy,
    "ftp" : ftp_proxy
    }
    610915518
    610915518
    Aug 2, 2022
    6
    无代码无真相
    mekingname
    mekingname
    Aug 2, 2022
    7
    他肯定是把 https 的代理的 scheme 写成 https 了。大多数代理网站都不提供 https 的代理。requests 的 proxies 字典里面,https 这个 key 对应的 value ,也应该是 http://开头。
    nyxsonsleep
    nyxsonsleep
    Aug 2, 2022
    8
    @mekingname #7 我印象中是 python 不同库有好几种写法。
    比如不能加 http 头的 proxy 。都要 http 头的 proxy 。分别要 http 和 https 头的 proxy 。
    kokutou
    kokutou
    Aug 3, 2022 via Android
    9
    我记得有个 bug 被修了,Python 和包都更新最新,然后再试试?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   886 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 23:51 · PVG 07:51 · LAX 15:51 · JFK 18:51
    ♥ Do have faith in what you're doing.