鱼C论坛

 找回密码
 立即注册
查看: 1839|回复: 3

Python运行后出现Traceback (most recent call last) 的问题

[复制链接]
发表于 2019-5-21 20:05:49 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
import urllib.request


url = 'http://www.whatismyip.com'

proxy_support = urllib.request.ProxyHandler({'http':'124.205.155.156:9090'})

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)


运行后


K:\untitled\venv\Scripts\python.exe K:/untitled/proxy.py
Traceback (most recent call last):
  File "D:\BIG DATA\Python\lib\urllib\request.py", line 1317, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "D:\BIG DATA\Python\lib\http\client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "D:\BIG DATA\Python\lib\http\client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "D:\BIG DATA\Python\lib\http\client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "D:\BIG DATA\Python\lib\http\client.py", line 1016, in _send_output
    self.send(msg)
  File "D:\BIG DATA\Python\lib\http\client.py", line 956, in send
    self.connect()
  File "D:\BIG DATA\Python\lib\http\client.py", line 928, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "D:\BIG DATA\Python\lib\socket.py", line 727, in create_connection
    raise err
  File "D:\BIG DATA\Python\lib\socket.py", line 716, in create_connection
    sock.connect(sa)
TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "K:/untitled/proxy.py", line 14, in <module>
    response = urllib.request.urlopen(url)
  File "D:\BIG DATA\Python\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "D:\BIG DATA\Python\lib\urllib\request.py", line 525, in open
    response = self._open(req, data)
  File "D:\BIG DATA\Python\lib\urllib\request.py", line 543, in _open
    '_open', req)
  File "D:\BIG DATA\Python\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "D:\BIG DATA\Python\lib\urllib\request.py", line 1345, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "D:\BIG DATA\Python\lib\urllib\request.py", line 1319, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。>

进程已结束,退出代码1

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-5-21 20:11:05 From FishC Mobile | 显示全部楼层
估计IP被封了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-5-21 20:36:55 | 显示全部楼层

嗯,是的。现在又有新问题,使用iplist随机选择IP,结果运行出来的结果是自己的真实IP,换了很多批结果出来都是自己的IP。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-5-21 23:06:12 | 显示全部楼层
有些诡异
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-1-15 22:09

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表