Skip to content

Instantly share code, notes, and snippets.

@ischurov
Last active December 12, 2015 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ischurov/1568b0debac15f51bd4a to your computer and use it in GitHub Desktop.
Save ischurov/1568b0debac15f51bd4a to your computer and use it in GitHub Desktop.
Get all page titles for pages in some category in Wikipedia (presently, names of all personalias are requested from ruwiki)
import requests
url = "https://ru.wikipedia.org/w/api.php"
query = {'action':'query',
'list':'categorymembers',
'cmtitle':'Категория: Персоналии по алфавиту',
'cmstartsortkeyprefix':'А',
'format':'json',
'cmlimit':500
}
names = []
for p in range(10):
data = requests.get(url,query).json()
for page in data['query']['categorymembers']:
names.append(page['title'])
print(page['title'])
if 'continue' in data:
query.update(data['continue'])
else:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment