使用python从单个维基百科页面API中提取所有Persondata

问题描述

我正在尝试提取维基百科页面中所有人的列表。在这种情况下,我想要所有带有元数据“Persondata”的链接,如维基百科所述。我发现了这个 SO question (Does the Wikipedia API support searches for a specific template?) 和 Metawiki (https://www.mediawiki.org/wiki/API:Embeddedin),但我不知道如何让它工作。我已经玩了几个小时的 API 无济于事。

import requests

S = requests.Session()

URL = "https://en.wikipedia.org/w/api.PHP"

ParaMS = {
    "action": "query","format": "json","list": "embeddedin","hashtemplate": "China","eilimit": "max"
}

R = S.get(url=URL,params=ParaMS)
DATA = R.json()

PAGES = DATA["query"]["embeddedin"]

for p in PAGES:
    print(p["title"])

在这种情况下,我只想要中国维基百科页面中所有人的列表。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)