Skip to main content

Wikipedia revision history parser for Python

Project description

WikiRevParser

WikiRevParser is a Python library that parses Wikipedia revision histories and allows you to analyse the development of pages on Wikipedia across all language versions.

The library extracts and parses Wikipedia revision histories from a language-page title pair and outputs clean, accessible data per timestamp in the revision history. You can use this library to access the development of references of a page, analyse the content or images over time, compare the tables of content across languages, create editor networks, and much more.

Example

To get the revision history for the page on Marie Curie on the English Wikipedia, run:

>>> from wikirevparser import wikirevparser
>>> parser_instance = wikirevparser.ProcessRevisions("en", "Marie Curie") 
>>> parser_instance.wikipedia_page()
>>> data = parser_instance.parse_revisions()

And you can access information like these:

about links:

>>> edits = list(data.items())
>>> first_links = edits[-1][1]["links"]
>>> latest_links = edits[0][1]["links"]
>>> print("The only link in the first version was '%s'. \nThere were %d links in the latest version, e.g. '%s'." % (first_links[0], len(latest_links), latest_links[0]))
The only link in the first version was 'pierre and marie curie'.
There were 320 links in the latest version, e.g. 'congress poland'.

about editors:

>>> from collections import Counter
>>> editors = Counter()
>>> for timestamp in data:
>>>	  editors[data[timestamp]["user"]] += 1
>>> most_frequent = editors.most_common(1)[0]
>>> print("%s has edited the page the most, all of %d times (%d percent)!" % (most_frequent[0], most_frequent[1], (most_frequent[1]/len(data)*100)))
Nihil novi has edited the page the most, all of 619 times (13 percent)!

You could also investigate the use of images, the changes in tables of content, analyse differences across different language versions, and much, much more.

Installation

To install WikiRevParser, you can clone the repository on GitHub or simply run:

>>> pip3 install wikirevparser

Requirements

The WikiRevParser requires Python 3+.

You'll also need a few common Python libraries as well as our Wikipedia API wrapper (forked from Wikipedia by @goldsmith), which extracts and returns the entire revision history of a Wikipedia page.

Run the following to install all requirements needed:

>>> python3 install -r requirements.txt
>>> git clone git@github.com:ajoer/Wikipedia.git

The first command installs all requirements specified in the requirements.txt file, and the second command clones our version of the Wikipedia API wrapper needed for revision history extraction.

Documentation

Read the docs at readthedocs.io

License

This work is MIT licensed. See the LICENSE file for full details.

Credits

  • @goldsmith for the Python Wikipedia API wrapper Wikipedia.
  • The Wikimedia Foundation and all Wikipedians for creating and maintaining the data.
  • This work has received funding from the European Union’s Horizon 2020 research and innovation programme under the Marie Skłodowska-Curie grant agreement No. 812997.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wikirevparser-0.0.5.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

wikirevparser-0.0.5-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file wikirevparser-0.0.5.tar.gz.

File metadata

  • Download URL: wikirevparser-0.0.5.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for wikirevparser-0.0.5.tar.gz
Algorithm Hash digest
SHA256 7c689ce8ba9551b49ece011c58aff86af5b9cbdb6c786943a97ee16dfdf21adc
MD5 15ff148d55cbf44675156a29ed8e3b8a
BLAKE2b-256 daa76c0206c0d6426e0908cf29736a5c6f1ab591c6bc59244d66134bd5e0e390

See more details on using hashes here.

File details

Details for the file wikirevparser-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: wikirevparser-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for wikirevparser-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 21c42d4942cff5df9364e1c8b8327e1297dc690ea79be45580da07e1298ac3f8
MD5 624323889abee985ff78ac70d800a37b
BLAKE2b-256 5c22bdbfc2673f013e3180ec0d3cbc9790bda0a7e895289587e34e3e249f29a4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page