从python那里获取Wikipedia的所有标题
我需要从意大利维基百科获取所有标题。我已经写了这个代码:
import requests
S = requests.Session()
URL = "https://it.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"format": "json",
"list": "allpages",
"aplimit": "max",
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
PAGES = DATA["query"]["allpages"]
for page in PAGES:
print(page['title'])
但是这只会给我打印出前500个标题。我如何获得其余标题?
i need to get all titles from italian wikipedia. I wrote already this code:
import requests
S = requests.Session()
URL = "https://it.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"format": "json",
"list": "allpages",
"aplimit": "max",
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
PAGES = DATA["query"]["allpages"]
for page in PAGES:
print(page['title'])
But this only prints me the first 500 titles. How can i get the rest of the titles?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用了您的请求,并找到了以下内容:
并且按照所有页面文档:
因此,要继续前进:
我不确定“批处理”键上的停止条件。请仔细检查,因为我没有在Wikipedia API页面上找到说明。
I used your request and found the following:
And as per All pages Documentation:
So to keep going do:
I'm not sure about the stopping condition on key "batchcomplete". Please double check as I didn't find an explanation on the wikipedia API page.