3 # ?action=query&titles=Albert%20Einstein&prop=categories
4 # Get the list of categories for the Albert Einstein article.
6 parameters = {'action' : 'query',
7 'titles' : 'Albert Einstein',
12 output_file = open("einstein_categories.list", 'w')
15 wp_call = requests.get('http://en.wikipedia.org/w/api.php', params=parameters)
16 response = wp_call.json()
18 for page_id in response["query"]["pages"].keys():
19 for category in response["query"]["pages"][page_id]['categories']:
20 print(category['title'], file=output_file)
22 if 'continue' in response:
23 parameters.update(response['continue'])