All Projects → siznax → Wptools

siznax / Wptools

Licence: mit
Wikipedia tools (for Humans): easily extract data from Wikipedia, Wikidata, and other MediaWikis

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Wptools

wikiapi
JavaScript MediaWiki API for node.js
Stars: ✭ 28 (-92.45%)
Mutual labels:  mediawiki, wikipedia, wikidata
wikibot
Some MediaWiki bot examples including wikipedia, wikidata using MediaWiki module of CeJS library. 採用 CeJS MediaWiki 自動化作業用程式庫來製作 MediaWiki (維基百科/維基數據) 機器人的範例。
Stars: ✭ 26 (-92.99%)
Mutual labels:  mediawiki, wikipedia, wikidata
Jivesearch
A search engine that doesn't track you.
Stars: ✭ 364 (-1.89%)
Mutual labels:  wikipedia, wikidata
WikibaseImport
Import entities from another Wikibase instance (e.g. Wikidata)
Stars: ✭ 25 (-93.26%)
Mutual labels:  mediawiki, wikidata
transparencia-dados-abertos-brasil
A survey of Brazilian states' and municipalities' transparency and open data portals, as well as institutional websites, obtained from several public data sources. 🇧🇷 Levantamento de portais estaduais e municipais de transparência e dados abertos, bem como os portais institucionais, obtido a partir de diversas fontes públicas de dados.
Stars: ✭ 46 (-87.6%)
Mutual labels:  wikidata, open-data
wikirepo
Python based Wikidata framework for easy dataframe extraction
Stars: ✭ 33 (-91.11%)
Mutual labels:  wikipedia, wikidata
WikidataR
An R package for the Wikidata API
Stars: ✭ 49 (-86.79%)
Mutual labels:  wikidata, api-client
entity-fishing
A machine learning tool for fishing entities
Stars: ✭ 176 (-52.56%)
Mutual labels:  wikipedia, wikidata
content-api-scala-client
A Scala client library for the Guardian's Content API
Stars: ✭ 37 (-90.03%)
Mutual labels:  api-client, open-data
pywikibot-scripts
Own pywikibot scripts (for Wikimedia projects)
Stars: ✭ 16 (-95.69%)
Mutual labels:  wikipedia, wikidata
copyvios
A copyright violation detector running on Wikimedia Cloud Services
Stars: ✭ 32 (-91.37%)
Mutual labels:  mediawiki, wikipedia
SemanticWikibase
Makes Wikibase data available in Semantic MediaWiki
Stars: ✭ 14 (-96.23%)
Mutual labels:  mediawiki, wikidata
go-wikidata
Wikidata API bindings in go.
Stars: ✭ 27 (-92.72%)
Mutual labels:  wikipedia, wikidata
cassandra-GLAM-tools
Support GLAMs in monitoring and evaluating their cooperation with Wikimedia projects
Stars: ✭ 17 (-95.42%)
Mutual labels:  mediawiki, wikipedia
Apd Core
Core repo for
Stars: ✭ 264 (-28.84%)
Mutual labels:  open-data, data-science
equalstreetnames
Map visualizing the streetnames by gender : 50 cities in 11 countries
Stars: ✭ 64 (-82.75%)
Mutual labels:  wikipedia, wikidata
Wikipedir
R's MediaWiki API client library
Stars: ✭ 54 (-85.44%)
Mutual labels:  api-client, mediawiki
discord-wiki-bot
Wiki-Bot is a bot with the purpose to easily search for and link to wiki pages. Wiki-Bot shows short descriptions and additional info about the pages and is able to resolve redirects and follow interwiki links.
Stars: ✭ 69 (-81.4%)
Mutual labels:  mediawiki, wikipedia
DiscordWikiBot
Discord bot for Wikimedia projects and MediaWiki wiki sites
Stars: ✭ 30 (-91.91%)
Mutual labels:  mediawiki, wikipedia
OA-signalling
A project to coordinate implementing a system to signal whether references cited on Wikipedia are free to reuse
Stars: ✭ 19 (-94.88%)
Mutual labels:  wikipedia, wikidata

Wikipedia tools (for Humans)

.. image:: https://img.shields.io/pypi/v/wptools.svg :target: https://pypi.python.org/pypi/wptools/

.. image:: https://travis-ci.org/siznax/wptools.svg?branch=master :target: https://travis-ci.org/siznax/wptools

.. image:: https://coveralls.io/repos/github/siznax/wptools/badge.svg?branch=master :target: https://coveralls.io/github/siznax/wptools

Python and command-line MediaWiki access for Humans

  • get page extracts, image, Infobox data, Wikidata, and more
  • get a random page, category, or site
  • get page statistics
  • get category members
  • get site info and stats
  • get data in any language

This package is intended to make it as easy as possible to get data from MediaWiki instances, expose more Wikidata, and extend Wikimedia APIs just for kicks. We say "(for Humans)" because that is a goal_. Questions, feedback, and especially contributions_ are welcome!

Install

.. code-block:: bash

$ pip install wptools
✨🦄✨

Example

.. code-block:: python

>>> import wptools

Get a page object:

.. code-block:: python

>>> page = wptools.page('Gandhi')

Get API:Query_ data:

.. _API:Query: https://www.mediawiki.org/wiki/API:Query

.. code-block:: python

>>> page.get_query()
en.wikipedia.org (query) Gandhi
en.wikipedia.org (imageinfo) File:Portrait Gandhi.jpg
Mahatma Gandhi (en) data
{
  aliases: <list(10)> M K Gandhi, Mohandas Gandhi, Bapu, Gandhi, M...
  assessments: <dict(10)> Pakistan, Alternative Views, South Afric...
  description: <str(67)> pre-eminent leader of Indian nationalism ...
  extext: <str(3077)> Mahātmā **Mohandas Karamchand Gandhi** ( ; H...
  extract: <str(3372)> <p>Mahātmā <b>Mohandas Karamchand Gandhi</b...
  image: <list(2)> {u'size': 2951123, 'kind': 'query-pageimage', u...
  label: Mahatma Gandhi
  length: 262,790
  links: <list(500)> 10 Janpath, 14th Dalai Lama, 1915 Singapore M...
  modified: <dict(1)> page
  pageid: 19379
  random: Salt
  redirected: <list(1)> {u'to': u'Mahatma Gandhi', u'from': u'Gandhi'}
  redirects: <list(53)> {u'ns': 0, u'pageid': 55342, u'title': u'M...
  requests: <list(2)> query, imageinfo
  title: Mahatma Gandhi
  url: https://en.wikipedia.org/wiki/Mahatma_Gandhi
  url_raw: https://en.wikipedia.org/wiki/Mahatma_Gandhi?action=raw
  watchers: 1,811
  wikibase: Q1001
  wikidata_url: https://www.wikidata.org/wiki/Q1001
}

Get API:Parse_ data:

.. _API:Parse: https://www.mediawiki.org/wiki/API:Parse

.. code-block:: python

>>> page.get_parse()
en.wikipedia.org (parse) Gandhi
en.wikipedia.org (imageinfo) File:MKGandhi.jpg
Mahatma Gandhi (en) data
{
  image: <list(1)> {u'size': 2951123, 'kind': 'parse-image', u'des...
  infobox: <dict(25)> known_for, other_names, image, signature, bi...
  iwlinks: <list(10)> https://biblio.wiki/wiki/Mohandas_K._Gandhi,...
  pageid: 19379
  parsetree: <str(331808)> <root><template><title>Redirect</title>...
  requests: <list(2)> parse, imageinfo
  title: Mahatma Gandhi
  wikibase: Q1001
  wikidata_url: https://www.wikidata.org/wiki/Q1001
  wikitext: <str(261349)> {{Redirect|Gandhi}}{{pp-move-indef}}{{pp...
}

Get Wikidata_:

.. _Wikidata: https://www.wikidata.org/w/api.php

.. code-block:: python

>>> page = wptools.page(wikibase='Q1001')
>>> page.get_wikidata()
www.wikidata.org (wikidata) Q1001
www.wikidata.org (labels) Q1280678|P535|P434|Q1860|P3762|Q668|P12...
www.wikidata.org (labels) P119|Q1930187|P691|P18|P19|P1066|P509|P...
www.wikidata.org (labels) Q6512732|Q1568|P972|Q84|P1430|P31|Q2140...
www.wikidata.org (labels) P1576|Q4964182|P1368|P140|Q22336956|P12...
en.wikipedia.org (imageinfo) File:Portrait Gandhi.jpg
Mahatma Gandhi (en) data
{
  aliases: <list(10)> M K Gandhi, Mohandas Gandhi, Bapu, Gandhi, M...
  claims: <dict(113)> P646, P535, P906, P434, P648, P3762, P1711, ...
  description: <str(67)> pre-eminent leader of Indian nationalism ...
  image: <list(1)> {u'size': 2951123, 'kind': 'wikidata-image', u'...
  label: Mahatma Gandhi
  labels: <dict(171)> Q1280678, P535, Q131149, P434, Q1860, P3762,...
  modified: <dict(1)> wikidata
  requests: <list(6)> wikidata, labels, labels, labels, labels, im...
  title: Mahatma_Gandhi
  what: human
  wikibase: Q1001
  wikidata: <dict(112)> Geni.com profile ID (P2600), National Libr...
  wikidata_pageid: 1330
  wikidata_url: https://www.wikidata.org/wiki/Q1001
}

Get RESTBase_ data:

.. _RESTBase: https://www.mediawiki.org/wiki/RESTBase

.. code-block:: python

>>> page.get_restbase('/page/summary/')
en.wikipedia.org (restbase) /page/summary/Gandhi
Mahatma Gandhi (en) data
{
  description: <str(67)> pre-eminent leader of Indian nationalism ...
  exhtml: <str(1168)> <p>Mahātmā <b>Mohandas Karamchand Gandhi</b>...
  exrest: <str(931)> Mahātmā Mohandas Karamchand Gandhi (; Hindust...
  image: <list(2)> {'kind': 'restbase-original', u'width': 2024, '...
  pageid: 19379
  requests: <list(1)> restbase
  title: Mahatma_Gandhi
  url: https://en.wikipedia.org/wiki/Gandhi
  url_raw: https://en.wikipedia.org/wiki/Gandhi?action=raw
}

Get all the things (at once):

.. code-block:: python

>>> page.get()
en.wikipedia.org (query) Gandhi
en.wikipedia.org (parse) 19379
www.wikidata.org (wikidata) Q1001
www.wikidata.org (labels) Q1280678|P535|P434|Q1860|P3762|Q668|P12...
www.wikidata.org (labels) P119|Q1930187|P691|P18|P19|P1066|P509|P...
www.wikidata.org (labels) Q6512732|Q1568|P972|Q84|P1430|P31|Q2140...
www.wikidata.org (labels) P1576|Q4964182|P1368|P140|Q22336956|P12...
en.wikipedia.org (restbase) /page/summary/Mahatma_Gandhi
en.wikipedia.org (imageinfo) File:MKGandhi.jpg|File:Portrait Gandhi.jpg
Mahatma Gandhi (en) data
{
  aliases: <list(10)> M K Gandhi, Mohandas Gandhi, Bapu, Gandhi, M...
  assessments: <dict(10)> Pakistan, Alternative Views, South Afric...
  claims: <dict(113)> P646, P535, P906, P434, P648, P3762, P1711, ...
  description: <str(67)> pre-eminent leader of Indian nationalism ...
  exhtml: <str(1168)> <p>Mahātmā <b>Mohandas Karamchand Gandhi</b>...
  exrest: <str(931)> Mahātmā Mohandas Karamchand Gandhi (; Hindust...
  extext: <str(3077)> Mahātmā **Mohandas Karamchand Gandhi** ( ; H...
  extract: <str(3372)> <p>Mahātmā <b>Mohandas Karamchand Gandhi</b...
  image: <list(6)> {u'size': 2951123, 'kind': 'query-pageimage', u...
  infobox: <dict(25)> known_for, other_names, image, signature, bi...
  iwlinks: <list(10)> https://biblio.wiki/wiki/Mohandas_K._Gandhi,...
  label: Mahatma Gandhi
  labels: <dict(171)> Q1280678, P535, Q131149, P434, Q1860, P3762,...
  length: 262,790
  links: <list(500)> 10 Janpath, 14th Dalai Lama, 1915 Singapore M...
  modified: <dict(2)> wikidata, page
  pageid: 19379
  parsetree: <str(331808)> <root><template><title>Redirect</title>...
  random: Salt
  redirected: <list(1)> {u'to': u'Mahatma Gandhi', u'from': u'Gandhi'}
  redirects: <list(53)> {u'ns': 0, u'pageid': 55342, u'title': u'M...
  requests: <list(9)> query, parse, wikidata, labels, labels, labe...
  title: Mahatma_Gandhi
  url: https://en.wikipedia.org/wiki/Mahatma_Gandhi
  url_raw: https://en.wikipedia.org/wiki/Mahatma_Gandhi?action=raw
  watchers: 1,811
  what: human
  wikibase: Q1001
  wikidata: <dict(112)> Geni.com profile ID (P2600), National Libr...
  wikidata_pageid: 1330
  wikidata_url: https://www.wikidata.org/wiki/Q1001
  wikitext: <str(261349)> {{Redirect|Gandhi}}{{pp-move-indef}}{{pp...
}

Get more (expensive) data:

.. code-block:: python

>>> page.get_more()
en.wikipedia.org (querymore) Gandhi
Mahatma Gandhi (en) data
{
  categories: <list(68)> Category:1869 births, Category:1948 death...
  contributors: 2,606
  files: <list(53)> File:Aum Om red.svg, File:Commons-logo.svg, Fi...
  languages: <list(168)> {u'lang': u'af', u'title': u'Mahatma Gand...
  pageid: 19379
  redirected: <list(1)> {u'to': u'Mahatma Gandhi', u'from': u'Gandhi'}
  requests: <list(1)> querymore
  title: Mahatma Gandhi
  views: 19,242
}

Get data in another language_:

.. _another language: https://github.com/siznax/wptools/wiki/Language-Codes

.. code-block:: python

>>> page = wptools.page(lang='zh')
zh.wikipedia.org (random) 🍰
哈莉特·塔布曼 (zh) data
{
  pageid: 211070
  title: 哈莉特·塔布曼
}

Get data from another wiki_:

.. _another wiki: https://meta.wikimedia.org/wiki/List_of_Wikipedias

.. code-block:: python

>>> page = wptools.page(wiki='en.wikiquote.org')
en.wikiquote.org (random) 🍪
Malala_Yousafzai (en)
{
  pageid: 146817
  title: Malala_Yousafzai
}

Documentation

See our wiki_.

Please enjoy!

@siznax 👹

.. _contributions: https://github.com/siznax/wptools/blob/master/CONTRIBUTING.md .. _goal: http://docs.python-requests.org/en/master/user/intro/ .. _wiki: https://github.com/siznax/wptools/wiki

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].