通过代理 IP 将 python 应用程序连接到互联网?
Connect python application to internet through proxy IP?
在我的工作场所,我们通过在首选项 > 网络 > 连接 > 手动代理配置中输入的代理服务器 IP 访问互联网。在输入代理 IP 的位置,我想了解如何在 python 中进行设置,以便我的基于 Internet 的应用程序。
您可以设置 http_proxy 环境变量,或者您可以根据使用的 lib 设置此信息。例如,请求库:
import requests
proxies = {
"http": "http://10.10.1.10:3128",
"https": "http://10.10.1.10:1080",
}
requests.get("http://example.org", proxies=proxies)
更新
可以在企业环境中提供帮助的工具是 cntlm http://cntlm.sourceforge.net/,它是一种 NTLM/NTLM 会话响应/NTLMv2 身份验证 HTTP 代理。
配置完成后,您只需在 http://localhost:3128 中指向您的代理即可。
在我的工作场所,我们通过在首选项 > 网络 > 连接 > 手动代理配置中输入的代理服务器 IP 访问互联网。在输入代理 IP 的位置,我想了解如何在 python 中进行设置,以便我的基于 Internet 的应用程序。
您可以设置 http_proxy 环境变量,或者您可以根据使用的 lib 设置此信息。例如,请求库:
import requests
proxies = {
"http": "http://10.10.1.10:3128",
"https": "http://10.10.1.10:1080",
}
requests.get("http://example.org", proxies=proxies)
更新
可以在企业环境中提供帮助的工具是 cntlm http://cntlm.sourceforge.net/,它是一种 NTLM/NTLM 会话响应/NTLMv2 身份验证 HTTP 代理。
配置完成后,您只需在 http://localhost:3128 中指向您的代理即可。