|
|
20鱼币
本帖最后由 沙漠王子 于 2017-1-31 11:18 编辑
- import urllib.request
- url = 'http://www.whatismyip.com.tw/'
- proxy_support = urllib.request.ProxyHandler({'http':'211.138.121.38:80'})
- 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)
复制代码
错误提示如图所示:
错误提示
经实验:
1.修改proxy_support = urllib.request.ProxyHandler({'http':'211.138.121.38:80'})中的IP为自己的IP后,出现相同的错误提示
2.直接输入response = urllib.request.urlopen('http://www.whatismyip.com.tw/'),出现相同的错误提示
3.输入response = urllib.request.urlopen('https://baike.baidu.com/'),可获取响应
4.用自己电脑登录网址'http://www.whatismyip.com.tw/',内容显示正常。 |
|