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
18
votes
5 answers

How to download images programmatically from Wikimedia Commons without registering for a Bot account?

It seems like the only way to get approval for a Bot account is if it adds to or edits information already on Wikimedia. If you try to download any images, without a bot account, using some of the api libraries out there you get error messages…
tomvon
  • 5,121
  • 3
  • 22
  • 16
11
votes
2 answers

Merging MediaWiki contents together

Currently I have two MediaWikis, one a slightly older version than the other. I want to merge the contents of both together, without eliminating duplicate pages. So far the best option I can think of is to use a bot (like pywikipedia) to go…
spelchec
  • 153
  • 1
  • 2
  • 8
9
votes
6 answers

How to speed up Pywikibot?

I've built some report tools using Pywikibot. As things are growing it now takes up to 2 hours to finish the reports so I'm looking to speed things up. Main ideas: Disable throttling, the script is read-only, so page.get(throttle=False) handles…
the
  • 21,007
  • 11
  • 68
  • 101
8
votes
6 answers

How do I get the HTML of a wiki page with Pywikibot?

I'm using pywikibot-core, and I used before another python Mediawiki API wrapper as Wikipedia.py (which has a .HTML method). I switched to pywikibot-core 'cause I think it has many more features, but I can't find a similar method. (beware: I'm not…
Aubrey
  • 507
  • 4
  • 20
6
votes
4 answers

Content of infobox of Wikipedia

I need to get the content of an infobox of any movie. I know the name of the movie. One way is to get the complete content of a Wikipedia page and then parse it until I find {{Infobox and then get the content of the infobox. Is there any other way…
Shruts_me
  • 843
  • 2
  • 12
  • 24
4
votes
0 answers

Running into Attribute Errors while trying to configure PyWikiBot

I am currently following the Python 3 Tutorial for Pywikibot and continue to experience attribute errors while running the included code from the tutorial as seen below. import pywikibot site = pywikibot.Site("en", "wikipedia") page =…
KullideDev
  • 41
  • 1
4
votes
0 answers

Using pywikibot, how to retrieve items with nested items inside?

Using this example, how do I retrieve the values of interaction on the electron page? I am stuck at this item_dict = item.get() clm_dict = item_dict["claims"] clm_list = clm_dict["P2069"] for clm in clm_list: clm_trgt = clm.getTarget() All I…
4
votes
2 answers

Pywikibot Installation

I was wondering if I could get some help setting up Pywikibot. I was able to download it using git clone --recursive https://gerrit.wikimedia.org/r/pywikibot/core.git following wikipedia page instructions. Where I get lost is when trying to create…
omonoia
  • 87
  • 4
4
votes
2 answers

Python: return empty value on exception

I have some experience in Python, but I have never used try & except functions to catch errors due to lack of formal training. I am working on extracting a few articles from wikipedia. For this I have an array of titles, a few of which do not have…
puslet88
  • 1,288
  • 15
  • 25
3
votes
2 answers

No user_config.py

We have an internal wiki and I want to use pywikibot to get some data from it. Installed it from pip but when I import it I get: >>> import pywikibot Traceback (most recent call last): File "", line 1, in File…
Larry Martell
  • 3,526
  • 6
  • 40
  • 76
3
votes
1 answer

How to create and or edit a page with pyWikiBot

The MediaWiki API has an edit function which is available within pywikibot. According to https://doc.wikimedia.org/pywikibot/master/api_ref/pywikibot.site.html the function is called with a page parameter: editpage(page, summary=None, minor=True,…
Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
3
votes
2 answers

Use pywikibot to download complete list of pages from a Mediawiki server without iterating through pages

I have a large (50K+ pages) Mediawiki wiki, and I need to efficiently get a list of all pages, sorted by last update time. I'm working in Python using pywikibot. The documentation hints that this is possible, but I haven't decoded how to do it…
Mark Olson
  • 136
  • 2
  • 9
3
votes
4 answers

How to login with pywikibot using password from environment variable?

I want to run pywikibot from inside Docker container, so I could run some cron jobs with it from the cloud (maybe Azure). I added code of my bot and user-config.py file to my Docker container, but when it tries to update some page, it uses getpass…
Bunyk
  • 7,635
  • 8
  • 47
  • 79
3
votes
1 answer

How to identify wikipedia categories in python

I am currently using pywikibot to obtain the categories of a given wikipedia page (e.g., support-vector machine) as follows. import pywikibot as pw print([i.title() for i in list(pw.Page(pw.Site('en'), 'support-vector machine').categories())]) The…
EmJ
  • 4,398
  • 9
  • 44
  • 105
3
votes
1 answer

Handling DisambiguationError?

I'm using the wikipedia library and I want to handle the DisambiguationError as an exception. My first try was try: wikipedia.page('equipment') # could be any ambiguous term except DisambiguationError: pass During execution line 3 isn't…
Jason
  • 884
  • 8
  • 28
1
2 3 4 5 6 7 8