Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 1.45 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Python Proxy Error With Requests Library
  2. proxyDict = {
  3.           'http'  : 'username:mypassword@77.75.105.165',
  4.           'https' : 'username:mypassword@77.75.105.165'
  5.         }
  6. r = requests.get("http://www.google.com", proxies=proxyDict)
  7.        
  8. Traceback (most recent call last):
  9. File "<pyshell#13>", line 1, in <module>
  10. r = requests.get("http://www.google.com", proxies=proxyDict)
  11. File "C:Python27libsite-packagesrequestsapi.py", line 78, in get
  12. :param url: URL for the new :class:`Request` object.
  13. File "C:Python27libsite-packagesrequestsapi.py", line 65, in request
  14. """Sends a POST request. Returns :class:`Response` object.
  15. File "C:Python27libsite-packagesrequestssessions.py", line 187, in request
  16. def head(self, url, **kwargs):
  17. File "C:Python27libsite-packagesrequestsmodels.py", line 407, in send
  18. """
  19. File "C:Python27libsite-packagesrequestspackagesurllib3poolmanager.py", line     127, in proxy_from_url
  20. File "C:Python27libsite-packagesrequestspackagesurllib3connectionpool.py", line    521, in connection_from_url
  21. File "C:Python27libsite-packagesrequestspackagesurllib3connectionpool.py", line 497, in get_host
  22. ValueError: invalid literal for int() with base 10: 'h6f2v6jh5dsxa@77.75.105.165'
  23.        
  24. import requests
  25. from requests.auth import HTTPProxyAuth
  26.  
  27. proxyDict = {
  28.           'http'  : '77.75.105.165',
  29.           'https' : '77.75.105.165'
  30.         }
  31. auth = HTTPProxyAuth('username', 'mypassword')
  32.  
  33. r = requests.get("http://www.google.com", proxies=proxyDict, auth=auth)