How can I set a single proxy for a requests session object?

后端 未结 4 1978
走了就别回头了
走了就别回头了 2020-12-15 06:42

I\'m using the Python requests package to send http requests. I want to add a single proxy to the requests session object. eg.

session = requests.Session()
s         


        
4条回答
  •  温柔的废话
    2020-12-15 07:08

    In fact, you are right, but you must ensure your defination of 'line', I have tried this , it's ok:

    >>> import requests
    >>> s = requests.Session()
    >>> s.get("http://www.baidu.com", proxies={'http': 'http://10.11.4.254:3128'})
    
    

    Did you define the line like line = ' 59.43.102.33:80', there is a space at the front of address.

提交回复
热议问题