|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- import urllib.request
- url='http://www.whatismyip.com.tw'
- proxy_support=urllib.request.ProxyHandler({'http':'121.234.225.6:37790'})
- 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)
复制代码
请问一下这段代码哪里有问题啊?运行结果显示:由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。换了几个ip地址也不成功,求指教,谢谢
楼主换个网站查:http://httpbin.org/get
然后刚刚去百度的 IP 试了试近7~8个才成功了一个:
- import urllib.request
- url='http://httpbin.org/get'
- proxy_support=urllib.request.ProxyHandler({'http':'101.4.136.34:81'})
- 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)
复制代码
趁热乎着,快去试试吧:
|
|