如何在python中从pywikibot获取重定向

如何在python中从pywikibot获取重定向,python,pywikibot,Python,Pywikibot,我想知道pywikibotapi是否允许检索给定维基百科文章的重定向 我尝试了以下方法 pw.Page(pw.Site('en'), 'forensics').showRedirects() pw.Page(pw.Site('en'), 'forensics').redirects() 但是,我在说AttributeError时出错:“Page”对象没有属性“showRedirects” 如果需要,我很乐意提供更多详细信息。使用: 旁注:还有: 但是这与反向链接不同page.getRefer

我想知道
pywikibot
api是否允许检索给定维基百科文章的重定向

我尝试了以下方法

pw.Page(pw.Site('en'), 'forensics').showRedirects()
pw.Page(pw.Site('en'), 'forensics').redirects()
但是,我在说AttributeError时出错:“Page”对象没有属性“showRedirects”

如果需要,我很乐意提供更多详细信息。

使用:


旁注:还有:

但是这与反向链接不同
page.getReferences(filter\u redirects=True)
返回不正确的页面

  • 重定向(但不必重定向到
    页面
  • 包含对
    页面的引用
这是罕见的,但也会发生。例如,假设页面A包含以下wikitext:

#Redirect[[C]]
{{B}}
此页面将通过
页面(站点“B”).getReferences(filter\u redirects=True)
返回,但不会通过
页面(站点“B”).backlinks(filter\u redirects=True)
返回

page.getReferences(filter_redirects=True)
#Redirect[[C]]
{{B}}