有没有办法获得维基百科的最终目的地url?

Is there a way to get the final destination of a wikipedia url?

我目前正在尝试使用任何可用语言的学名获取鸟类的描述页面。例如,使用科学名称 "Ibycter americanus" 作为“https://en.wikipedia.org/wiki/", the browser redirects me to the english wikipedia page. If I use the subdomain "fr", to get it in french, I am redirected to the french page”的端点。

这一切在浏览器中运行良好,但我无法在 python 代码中获得最终的 url:

req = urllib2.Request("https://en.wikipedia.org/wiki/" + "Ibycter americanus")
res = urllib2.urlopen(req)
finalurl = res.geturl()
print(finalurl)

最后的url 总是“https://en.wikipedia.org/wiki/Ibycter_americanus", and not "https://en.wikipedia.org/wiki/Red-throated_caracara”,就像它在浏览器中显示的那样。有什么想法吗?

最好使用 API 来做这样的事情。例如。 action=query&titles=Ibycter+americanus&redirects=1