Questions tagged [pywikibot]

Pywikibot is a Python library to access the MediaWiki API.

Pywikibot

Pywikibot is a library to access the MediaWiki API. Its former name was .

Useful links

119 questions
2
votes
1 answer

How I can parallelize a 'for' loop with an external variable?

I am having difficulties parallelizing that part of code where new_text is of type unicode: for old, new in self.replacements: line = pywikibot.replaceExcept( line, old, new, self.excsInside, self.site) if new_text != entry.text: …
user2284570
  • 2,891
  • 3
  • 26
  • 74
1
vote
2 answers

pywikipedia name wikiquote is not defined?

I'm writing a bot for Wikipedia but have a problem. When I want to get stuff from another Wikimedia site I get the error - error-name 'wikiquote' is not defined. This is when I start the code off like this- import wikipedia site =…
Solihull
  • 6,779
  • 5
  • 22
  • 12
1
vote
0 answers

How to move mutiple categories using Pywikibot and category.py?

I know a single category can be moved by using like this: python pwb.py category move -from:Apple -to:Banana But, I can't find the way to move mass categories in just one command. Is there any options like -pairsfile in movepages.py? It would be…
shapino
  • 11
  • 2
1
vote
1 answer

Sparql Query for wikidata to get multiple values from property

I am trying to create a wiki data SPARQL query. What I want to do is to get multiple items from the some property For example: I am trying to fetch all data that have property of instance of statistical packages. But the problem I am facing is for…
Abdul Muqeet
  • 65
  • 2
  • 8
1
vote
2 answers

How do I use pywikibot.Page(site, title).text when the title has an unescaped apostrophe (')?

I have a list of strings called cities, where each string is a city name that is also the title of a wikipedia page. For each city, I'm getting the wikipedia page and then looking at the text content of it: cities = [(n["name"]) for n in…
sam_ur_ai
  • 107
  • 10
1
vote
1 answer

How do I get a list of all of the quotes for a particular person from the mediawiki API?

I am trying to get a list of all of Kurt Cobain's quotes from the mediawiki api. I have: https://en.wikiquote.org/w/api.php?format=json&action=query&srsearch=Kurt+Cobain&list=search BUT, it doesn't seem to give me any of his quotes as shown…
user_78361084
  • 3,538
  • 22
  • 85
  • 147
1
vote
3 answers

Wikipedia revision history using pywikibot

I want to collect all the revisions history data at once. Pywikibot page.revisions() does not have the parameter to fetch number of bytes changed. It gives me all the data that I need except the number of bytes changed. How do I get the number of…
1
vote
1 answer

How to get all contributions of a wikipedia user?

Given a Wikipedia user/editor id and a timeframe, is there a way in Python to get details about all the contributions/edits made the user/editor? I want to fetch details like page edited, action taken, bytes added/deleted in case of revision, and…
1
vote
0 answers

How to add a numeric value with unit (eg. 1500 kW) using WbQuantity() function, unsuccessful using tutorial

I'm creating a semi-automated tool in Python, using pywikibot, to import data from TOP500 database into Wikidata, following this and this tutorial. (Is my first time programming in Python). It ran fine, until the script attempts to commit a numeric…
Amitie 10g
  • 81
  • 1
  • 7
1
vote
1 answer

Is there a way to use the variable "title of the current page" inside a pywikibot replace command?

I would like my pywikibot to remove | name = whatever from a wikipedia infobox if the name is equal to the title of the page using the replace function. Is there an easy way to do that? The code to use should be something like that: $ python pwb.py…
Pau Cabot
  • 13
  • 4
1
vote
1 answer

Get plain text from Wikipedia API by sections

I'm trying to get plain(without html/css/special characters/ characters like \n/links/images) text of section using wikipedia api. I trying to do that with this code import requests API_URL = 'http://en.wikipedia.org/w/api.php' def…
Levon
  • 41
  • 4
1
vote
1 answer

How can I find all Featured Articles with pywikibot?

I have this piece of code that find all the wikipedia articles that have the template dubious using the library pywikibot: pages = pywikibot.Page(site, "Template:Dubious").getReferences(namespaces = 0) Now I need to find all Featured articles. I…
1
vote
2 answers

How to count number of citations/references in wikipedia raw text?

I'm building a model to classify raw Wikipedia text by article quality (Wikipedia has a dataset of ~30,000 hand-graded articles and their corresponding quality grades.). Nonetheless, I am trying to figure out a way to algorithmically count the…
Austin
  • 401
  • 1
  • 4
  • 8
1
vote
1 answer

How to use the Mediawiki API to create pages with longform texts and lists in python

I recently learned how to scrape my mom's recipes from a cooking website. My current goal is to put those recipes into a self-hosted mediawiki server. Since all I know is python, I'm trying to use GET and POST requests and the API to create these…
sc4s2cg
  • 153
  • 9
1
vote
2 answers

How can i know that a specific Index template parameter is empty by pywikibot?

I am trying to fill-up page numbers of a Book in its Index Wikisource page. The following code writes well in the specific pageNumber parameter. If the page is empty, it looks fine. But if i run the code another time, due to the concatenation the…
info-farmer
  • 255
  • 3
  • 18