Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- urllib.error.URLError: <urlopen error Tunnel connection failed: 407
- Proxy Authentication Required>
- header = {
- 'User-Agent': "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36"}
- proxy_host = '0.0.0.0:20829'
- PROXY_USERNAME = b'uername'
- PROXY_PASSWORD = b'password'
- proxy_auth = urlsafe_b64encode(b'%s:%s' % (PROXY_USERNAME,
- PROXY_PASSWORD))
- req = Request(url, headers=header)
- req.set_proxy(proxy_host, 'https')
- req.add_header('Proxy-Authorization', 'Basic %s' % proxy_auth)
- response = urlopen(req)
- return BeautifulSoup(response, 'html.parser')
Add Comment
Please, Sign In to add comment