马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
网上找的代理ip试了很多个运行起来都是这样的错。。这是为什么呢。代码写错了吗?
import urllib.request
url='http://www.whatismyip.com.tw'
proxy_support = urllib.request.ProxyHandler({'http':'218.56.132.157:8080'})
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)
运行结果
>>>
================ RESTART: C:\Users\lenovo\Desktop\mydaili.py ================
Traceback (most recent call last):
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python35\lib\urllib\request.py", line 1254, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 1151, in _send_request
self.endheaders(body)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 1102, in endheaders
self._send_output(message_body)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 934, in _send_output
self.send(msg)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 877, in send
self.connect()
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 849, in connect
(self.host,self.port), self.timeout, self.source_address)
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python35\lib\socket.py", line 711, in create_connection
raise err
File "C:\Users\lenovo\AppData\Local\Programs\Python\Python35\lib\socket.py", line 702, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
新手上路,希望大神多多指教,不胜感激~ |