Reputation: 161
I'm trying to find an API that allows me to easily get the total number of views for a given wikipedia page. Does anyone know if something that does that exists for python ?
Upvotes: 0
Views: 2100
Reputation: 1398
Try using Pageview API. There are some examples there of how you should interact with the API via HTTP
To do this in python you could, for example, use the requests
library. Simple example:
import requests
resp = requests.get('https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/en.wikipedia/all-access/all-agents/Albert_Einstein/daily/2015100100/2015103100')
data = resp.json()
print(data['items'][0]['views'])
Upvotes: 2