Guest User

Untitled

a guest
Aug 27th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. urllib.error.URLError: <urlopen error Tunnel connection failed: 407
  2. Proxy Authentication Required>
  3.  
  4. header = {
  5. 'User-Agent': "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36"}
  6.  
  7. proxy_host = '0.0.0.0:20829'
  8. PROXY_USERNAME = b'uername'
  9. PROXY_PASSWORD = b'password'
  10. proxy_auth = urlsafe_b64encode(b'%s:%s' % (PROXY_USERNAME,
  11. PROXY_PASSWORD))
  12. req = Request(url, headers=header)
  13. req.set_proxy(proxy_host, 'https')
  14. req.add_header('Proxy-Authorization', 'Basic %s' % proxy_auth)
  15. response = urlopen(req)
  16. return BeautifulSoup(response, 'html.parser')
Add Comment
Please, Sign In to add comment