added a version of the final program that writes to a file
[wikipedia-api-cdsw] / wikipedia4.py
diff --git a/wikipedia4.py b/wikipedia4.py
deleted file mode 100644 (file)
index 1798d1a..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-import requests
-
-# ?action=query&titles=Albert%20Einstein&prop=categories
-# Get the list of categories for the Albert Einstein article.
-
-parameters = {'action' : 'query',
-              'titles' : 'Albert Einstein',
-              'prop' : 'categories',
-              'format' : 'json',
-              'continue' :  ''}
-
-while True:
-    wp_call = requests.get('http://en.wikipedia.org/w/api.php', params=parameters)
-    response = wp_call.json()
-
-    for page_id in response["query"]["pages"].keys():
-        for category in response["query"]["pages"][page_id]['categories']:
-            print(category['title'])
-
-    if 'continue' in response:
-        parameters.update(response['continue'])
-    else:
-        break
-

Benjamin Mako Hill || Want to submit a patch?