This is a wrapper around Wikipedia's PageView API with the following endpoints:
- Retrieves a list of the most viewed articles for a week or month
- Retrieves the view count for an article for a specified week or month
- Retrieve the day of the month where an article got the most page views
- This project is using articles from en.wikipedia only
- Access type is all-access (view counts are spread across desktop, mobile-app, and mobile-web)
- Agent type is user for per-article requests
- Using coolbot as the user-agent
You can install this package by using pip
pip install -i https://test.pypi.org/simple/ wiki-wrapper-adamn11
If you run into an error that says "module 'collections' has no attribute 'MutableMapping'"
, you have to update the requests package by running
pip install requests --upgrade
To start using this package, you need to import wiki-api-wrapper and then instantiate an instance of WikiWrapper()
from wiki_wrapper_adamn11.wiki_wrapper import WikiWrapper
wiki = WikiWrapper()
wiki.get_list_of_most_viewed_articles_month(2022, 10)
Which should return a list like the one below
['Special:Search', 'Main_Page', 'Special:CreateAccount', '1911_Encyclopædia_Britannica/Bidpai,_Fables_of', 'National_Pledge_(India)', 'special:search', 'Atlas_of_the_World_Battle_Fronts_in_Semimonthly_Phases_to_August_15_1945', 'Special:ElectronPdf', 'Zodiac_Killer_letters', 'The_Rig_Veda']
wiki.get_view_count_of_article("Albert Einstein", "month", 2022, 4)
Should return an int of 385712
wiki.get_article_date_with_most_views("Albert Einstein")
Should return a datetime of 2018-03-14 00:00:00