]> code.communitydata.science - covid19.git/commitdiff
fix bugs with the date stamps
authorBenjamin Mako Hill <mako@atdot.cc>
Wed, 1 Apr 2020 15:47:33 +0000 (10:47 -0500)
committerBenjamin Mako Hill <mako@atdot.cc>
Wed, 1 Apr 2020 15:47:33 +0000 (10:47 -0500)
wikipedia/scripts/fetch_enwiki_daily_views.py
wikipedia/scripts/fetch_enwiki_revisions.py

index c250bfe94aa23106bc900556b93e142860213532..225b06d7aaaa0135a78b75cbcdc7625dce5f366f 100755 (executable)
@@ -47,8 +47,6 @@ def main():
         yesterday = datetime.datetime.today() - datetime.timedelta(days=1)
         queryDate = yesterday.strftime("%Y%m%d")
 
-    queryDate = queryDate + "00" #requires specifying hours
-
     #handle -L
     loglevel_mapping = { 'debug' : logging.DEBUG,
                          'info' : logging.INFO,
@@ -92,7 +90,7 @@ def main():
         #2 Repeatedly call the API with that list of names
         for a in articleList:
             a = a.strip("\"\n") #destringify
-            url= f"https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/en.wikipedia/all-access/all-agents/{a}/daily/{queryDate}/{queryDate}"
+            url= f"https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/en.wikipedia/all-access/all-agents/{a}/daily/{queryDate}00/{queryDate}00"
 
             response = requests.get(url)
             if response.ok:
index cbb283d641c601c50b7d28f7d743210367a610f8..3ecd04f5370f890a04d45f11a39cb8f76b17d84c 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!yusr/bin/env python3
 
 ###############################################################################
 #
@@ -44,8 +44,6 @@ def main():
         yesterday = datetime.datetime.today() - datetime.timedelta(days=1)
         query_date = yesterday.strftime("%Y%m%d")
 
-    query_data  = query_date + "00" #requires specifying hours
-
     #handle -L
     loglevel_mapping = { 'debug' : logging.DEBUG,
                          'info' : logging.INFO,
@@ -73,7 +71,7 @@ def main():
     logging.info(f"Last commit: {export_git_hash}")
 
     json_output_filename = os.path.join(output_path, f"digobs_covid19-wikipedia-enwiki_revisions-{query_date}.json")
-    tsv_output_filename =  os.path.join(output_path, f"digobs_covid19-wikipedia-enwiki_revisions-{query_data}.tsv")
+    tsv_output_filename =  os.path.join(output_path, f"digobs_covid19-wikipedia-enwiki_revisions-{query_date}.tsv")
     
     api_session = api.Session("https://en.wikipedia.org/w/api.php")
 

Community Data Science Collective || Want to submit a patch?