CarrotFish 发表于 2020-3-31 08:47:56

报错 ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

count = 0
#检测网络状态
def is_net(path = 'http://carrotfishstudio.com'):
    global count
    header = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36"}
    try:
      web.urlopen(web.Request(path, headers = header), timeout = 100).read()
    except:
      if count < 10:
            count += 1
            is_net(path)
      return False
    return True


如果不加 except 就会报错 ConnectionRefusedError: 由于目标计算机积极拒绝,无法连接。

使用urllib访问我自己的网站 carrotfishstudio.com 开放80端口 Chrome 和 Ping 都是可以访问的

请问这如何解决

永恒的蓝色梦想 发表于 2020-3-31 09:44:53

这个web是个什么东西

一个账号 发表于 2020-3-31 10:03:51

请发完整代码

NZND 发表于 2020-4-3 14:17:17

你是不是用任务管理器之类的强制结束了进程?
页: [1]
查看完整版本: 报错 ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。