【问题标题】:wikipedia.method() doesn't return anythingwikipedia.method() 不返回任何内容
【发布时间】:2021-11-22 14:58:52
【问题描述】:

当我使用任何维基百科方法时出现超时错误,有什么方法可以解决吗?他们有 20% 的时间在工作 这就是我尝试运行的:

import wikipedia

print(wikipedia.languages())

我得到了什么:

TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "C:\Users\zoomee\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connectionpool.py", line 706, in urlopen
    chunked=chunked,
  File "C:\Users\zoomee\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "C:\Users\zoomee\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "C:\Users\zoomee\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\zoomee\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\zoomee\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\zoomee\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1026, in _send_output
    self.send(msg)
  File "C:\Users\zoomee\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 966, in send
    self.connect()
  File "C:\Users\zoomee\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connection.py", line 205, in connect
    conn = self._new_conn()
  File "C:\Users\zoomee\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connection.py", line 187, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000001D0431E4A08>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

【问题讨论】:

  • 编辑信息

标签: python connection timeout wikipedia


【解决方案1】:

这个包引用了一个 API,所以如果你没有连接到网络,它将无法工作。此外,它的最后一次更新是在 2014 年,这意味着如果在过去 7 年中 API 或表结构发生任何变化,那么这个包可能已经过时了。您应该检查软件包文档以及 Wikipedia 的 API 文档以确保它是最新的。

Wiki API

Wiki Package

【讨论】:

    猜你喜欢
    • 2020-04-27
    • 2019-04-06
    • 2012-02-15
    • 2020-09-07
    • 2015-11-06
    • 2013-11-14
    • 2014-03-23
    • 2012-08-25
    • 1970-01-01
    相关资源
    最近更新 更多