Skip to main content
 首页 » 编程设计

python之当页面存在时从维基百科搜索查询错误加载页面

2024年12月31日17fff_TT

当页面确实存在时运行此代码会出错,因为我首先使用 python 维基百科库获取页面。

import wikipedia 
 
wikiResults = wikipedia.search("megaman 64") 
result = wikiResults[0] 
page = wikipedia.page(result) 

返回的错误:

wikipedia.exceptions.PageError: Page id "mega man legends video games" does  
not match any pages. Try another id! 

我做错了什么?

谢谢

编辑:提供 MCVE

请您参考如下方法:

我通过查看 github 已解决的问题修复了这个错误。

当运行以下行时,自动建议自动设置为 true

page = wikipedia.page(result) 

禁用此功能可以解决问题:

page = wikipedia.page(result, auto_suggest=False)