At my workplace we access internet through a proxy server IP entered in Preferences > Network > Connection > Manual Proxy configuration. where the Proxy IP is entered, I want to learn how to do that setup in python so for my internet based application .
在我的工作场所,我们通过在首选项>网络>连接>手动代理配置中输入的代理服务器IP访问互联网。在输入代理IP的地方,我想学习如何在python中进行设置,以便我的基于互联网的应用程序。
1 个解决方案
#1
You can set http_proxy environment variable or you can set this information accordly with lib used. As example, requests libs:
您可以设置http_proxy环境变量,也可以根据所使用的lib设置此信息。例如,请求libs:
import requests
proxies = {
"http": "http://10.10.1.10:3128",
"https": "http://10.10.1.10:1080",
}
requests.get("http://example.org", proxies=proxies)
UPDATE
A tool that can help in corporate environments is cntlm http://cntlm.sourceforge.net/ , an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy.
可以在企业环境中提供帮助的工具是cntlm http://cntlm.sourceforge.net/,NTLM / NTLM会话响应/ NTLMv2验证HTTP代理。
Once configured, you only have to point to your proxy in http://localhost:3128.
配置完成后,您只需在http:// localhost:3128中指向您的代理。
#1
You can set http_proxy environment variable or you can set this information accordly with lib used. As example, requests libs:
您可以设置http_proxy环境变量,也可以根据所使用的lib设置此信息。例如,请求libs:
import requests
proxies = {
"http": "http://10.10.1.10:3128",
"https": "http://10.10.1.10:1080",
}
requests.get("http://example.org", proxies=proxies)
UPDATE
A tool that can help in corporate environments is cntlm http://cntlm.sourceforge.net/ , an NTLM / NTLM Session Response / NTLMv2 authenticating HTTP proxy.
可以在企业环境中提供帮助的工具是cntlm http://cntlm.sourceforge.net/,NTLM / NTLM会话响应/ NTLMv2验证HTTP代理。
Once configured, you only have to point to your proxy in http://localhost:3128.
配置完成后,您只需在http:// localhost:3128中指向您的代理。