Install the Python library pageviewapi, that uses the PageView API from Wikimedia Foundation.
pip3 install git+https://github.com/Commonists/pageview-api.git
Download and extract Pywikibot, a Python library for interacting with Wikipedia:
wget https://tools.wmflabs.org/pywikibot/core_stable.tar.gz
tar xzf core_stable.tar.gz
- Then generate your bot password on https://www.mediawiki.org/wiki/Special:BotPasswords (or the corresponding page on another wiki).
- After setting rights and range (i.e., 0.0.0.0) you will receive a message like The new password to log in with Valhallasw@my-botpassword-name is mysupersecretbotpassword.
- Do not close this window until you saved the password in your password file.
- Run
python3 pwb.py generate_user_files
and use your credentials in the prompt. - After the user files have been generated
user-password.py
anduser-config.py
are available, which should contain the credentials. - Run
python3 pwb.py login
for verification.
Extract data from Wikipedia using wiki.py:
python3 core_stable/pwb.py wiki.py --languages "Theodor Fontane" > interwiki.tsv
Plot some of the columns using interwiki.gpi:
gnuplot interwiki.gpi
Starting point is the Wikipedia category https://de.wikipedia.org/wiki/Kategorie:Werk_von_Theodor_Fontane.
Extract data from Wikipedia using wiki.py:
python3 core_stable/pwb.py wiki.py --category "Kategorie:Werk_von_Theodor_Fontane" > works.tsv
Plot some of the columns using works.gpi:
gnuplot works.gpi
Download the result of the SPARQL query https://w.wiki/aNi as TSV file contemporaries_wikidata.tsv and then extract data from Wikipedia using wiki.py:
python3 core_stable/pwb.py wiki.py --file contemporaries_wikidata.tsv > contemporaries.tsv
Plot some of the columns using contemporaries.gpi:
gnuplot contemporaries.gpi