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