在没有系统默认代理的情况下使用 URLLIB Python

发布于 2024-09-28 12:54:20 字数 86 浏览 0 评论 0原文

我有一个小脚本需要与我通信,它是我代理的一部分。该脚本需要在代理启动之前运行,但系统设置为使用代理,因此它没有通过。我如何使用 urllib,而不是默认代理?

I have a small script that needs to communicate with me, it is part of my proxy. The script needs to run before the proxy starts, but the system is set to use the proxy, so it does not go through. How would I use urllib, but not the default proxy?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小镇女孩 2024-10-05 12:54:20

urllib 文档

urllib.urlopen(url[, 数据[, 代理]])

[...]
或者,可选的 proxies 参数可用于显式指定代理。它必须是一个将方案名称映射到代理 URL 的字典,其中空字典会导致不使用代理,而 None(默认值)会导致使用环境代理设置,如上所述。 [...]

所以只需使用 proxies={}

urllib docs:

urllib.urlopen(url[, data[, proxies]])

[...]
Alternatively, the optional proxies argument may be used to explicitly specify proxies. It must be a dictionary mapping scheme names to proxy URLs, where an empty dictionary causes no proxies to be used, and None (the default value) causes environmental proxy settings to be used as discussed above. [...]

So just use proxies={}.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文