barrust / mediawiki

MediaWiki API wrapper in python http://pymediawiki.readthedocs.io/en/latest/
MIT License
180 stars 29 forks source link

Yugipedia gives an error #139

Closed firas5673 closed 2 months ago

firas5673 commented 2 months ago

When I try using it with 'https://yugipedia.com/api.php', I get an error saying

mediawiki.exceptions.MediaWikiAPIURLError: https://yugipedia.com/api.php is not a valid MediaWiki API URL

Even though they DO use MediaWiki.

barrust commented 2 months ago

It looks like this API might require a login.

The following code, which just tries to get a particular page (Asian-Ensligh), returns a forbidden status code.

import requests
r = requests.get("https://yugipedia.com/api.php", params={"prop": "extracts|revisions", "explaintext": "", "rvprop": "ids", "action": "query", "titles":"Asian-English"})
print(r.status_code)

I could make the exception a bit more specific in the case of a forbidden but I can't know for sure if a username and password are required.

barrust commented 2 months ago

see branch issue-139 for a potential improvement on a forbidden status code