|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- import urllib.request
- #url = 'http://www.whatismyip.com.tw'
- #proxy_support = urllib.request.ProxyHandler({'http':'47.57.188.208:80'})
- url = 'http://www.whatismyip.com.tw'
- proxy_support = urllib.request.ProxyHandler({'http':'47.57.188.208:80'})
- #为何以上两组代码完全一致但使用上方代码便会报错(rllib.error.HTTPError: HTTP Error 504: Gateway Time-out)
- opener = urllib.request.build_opener(proxy_support)
- urllib.request.install_opener(opener)
- response = urllib.request.urlopen(url)
- html = response.read().decode('utf-8')
- print(html)
复制代码
- import urllib.request
- #url = 'http://www.whatismyip.com.tw'
- #proxy_support = urllib.request.ProxyHandler({'http':'47.57.188.208:80'})
- url = 'https://www.kuaidaili.com/free/' # 换个网站
- proxy_support = urllib.request.ProxyHandler({'http': '47.57.188.208:80'})
- # 为何以上两组代码完全一致但使用上方代码便会报错(rllib.error.HTTPError: HTTP Error 504: Gateway Time-out)
- opener = urllib.request.build_opener(proxy_support)
- urllib.request.install_opener(opener)
- response = urllib.request.urlopen(url, timeout=1)
- html = response.read().decode('utf-8')
- print(html)
复制代码
|
|