[英]python simple_salesforce proxy usage
I'm using python simple_salesforce module from this example: https://pypi.python.org/pypi/simple-salesforce . 我正在从以下示例中使用python simple_salesforce模块: https : //pypi.python.org/pypi/simple-salesforce 。 Specifically: 特别:
proxies = { "http": "http://10.10.1.10:3128" }
from simple_salesforce import Salesforce sf = Salesforce(username='myemail@example.com.sandbox', password='password', security_token='token', sandbox=True, proxies=proxies)
proxies = { "http": "http://10.10.1.10:3128" }
from simple_salesforce import Salesforce sf = Salesforce(username='myemail@example.com.sandbox', password='password', security_token='token', sandbox=True, proxies=proxies)
Its failing with the below error. 其失败并显示以下错误。 requests.exceptions.ConnectionError: ('Connection aborted.', error(111, 'Connection refused'))
If I dont use proxy, it works fine. 如果我不使用代理,它会正常工作。 My requirement is to enable proxy. 我的要求是启用代理。 Any suggestions? 有什么建议么?
Adding the following to the beginning of the program will solve this problem. 在程序的开头添加以下内容将解决此问题。 I was using urllib2 in python and that takes care of forwarding the request through proxy. 我在python中使用urllib2,它负责通过代理转发请求。 For the answer to my question: 对于我的问题的答案:
If your hostname and port for proxy are xyz1-pqr01.abc.company.com and 3128 then import os os.environ['http_proxy'] = 'http://xyz1-pqr01.abc.company.com:3128' os.environ['https_proxy'] = 'http://xyz1-pqr01.abc.company.com:3128'
如果代理的主机名和端口是xyz1-pqr01.abc.company.com和3128,则import os os.environ['http_proxy'] = 'http://xyz1-pqr01.abc.company.com:3128' os.environ['https_proxy'] = 'http://xyz1-pqr01.abc.company.com:3128'
//xyz1-pqr01.abc.company.com:3128'os import os os.environ['http_proxy'] = 'http://xyz1-pqr01.abc.company.com:3128' os.environ['https_proxy'] = 'http://xyz1-pqr01.abc.company.com:3128'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.