Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using mediawiki site other than Wikipedia #45

Open
matkoniecz opened this issue Dec 7, 2020 · 7 comments
Open

Allow using mediawiki site other than Wikipedia #45

matkoniecz opened this issue Dec 7, 2020 · 7 comments

Comments

@matkoniecz
Copy link

There are also many other Mediawiki installs and sites except Wikipedia, with the same API.

It would be nice to have access to them.

@lehinevych
Copy link
Owner

@matkoniecz great idea. I'll address it in next release

@GHolk
Copy link

GHolk commented Dec 15, 2022

It seem we can pass a config with overwriten config.API_URL while initialization to interact with other Mediawiki instance?

@ManuelSchneid3r
Copy link

Indeed. I found here because I need a generalizing mediawiki client. Please implement this or at least rename the project

@lehinevych
Copy link
Owner

@GHolk yes, you can overwrite the config.API_URL and it should work if the site support the localization.

@GHolk @ManuelSchneid3r can you please provide me the example of sites you want to use the client for so I can perform the testing of the code changes?

@ManuelSchneid3r
Copy link

Maybe Arch Linux wiki

@GHolk
Copy link

GHolk commented Dec 28, 2022

I found mediawiki's bot tutorial provide a powerful module Pywikibot, thought I had not really used both of these modules.

I intended to use this module in Fandom and a Taiwanese ACG wiki (both in chinese), but I do not think it is convenient for you to test your code there.

Please DM me if you really want to and/or need helps.

@rhodges
Copy link

rhodges commented Aug 26, 2023

Python v3.11
MediaWikiAPI v1.2

This seems to be close:

>>> import mediawikiapi
>>> explain_xkcd_wiki = mediawikiapi.MediaWikiAPI(config=mediawikiapi.Config(mediawiki_url="https://www.explainxkcd.com/wiki/api.php"))
>>> explain_page = explain_xkcd_wiki.page('2715')
>>> explain_page.title
'2715: Pando'

However, not every bit works:

>>> explain_page.summary
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rhodges/anaconda3/envs/hero/lib/python3.11/site-packages/mediawikiapi/wikipediapage.py", line 309, in summary
    self._summary: str = request["query"]["pages"][self.pageid]["extract"]
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'extract'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants