alexz-enwp / wikitools

Python package for working with MediaWiki wikis
105 stars 51 forks source link

wikitools.wiki.Wiki for biografias.bcn.cl: Invalid JSON #55

Open nemobis opened 6 years ago

nemobis commented 6 years ago
>>> import wikitools
>>> site = wikitools.wiki.Wiki('http://biografias.bcn.cl/api.php')
Invalid JSON, trying request again
Invalid JSON, trying request again
Invalid JSON, trying request again
Invalid JSON, trying request again
Invalid JSON, trying request again
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/federico/.local/lib/python2.7/site-packages/wikitools/wiki.py", line 95, in __init__
    self.setSiteinfo()
  File "/home/federico/.local/lib/python2.7/site-packages/wikitools/wiki.py", line 113, in setSiteinfo
    info = req.query(False)
  File "/home/federico/.local/lib/python2.7/site-packages/wikitools/api.py", line 158, in query
    rawdata = self.__getRaw()
  File "/home/federico/.local/lib/python2.7/site-packages/wikitools/api.py", line 270, in __getRaw
    data = gzip.GzipFile('', 'rb', 9, StringIO.StringIO(data.read()))
  File "/usr/lib64/python2.7/socket.py", line 355, in read
    data = self._sock.recv(rbufsize)
  File "/usr/lib64/python2.7/httplib.py", line 597, in read
    s = self.fp.read(amt)
  File "/usr/lib64/python2.7/socket.py", line 384, in read
    data = self._sock.recv(left)
KeyboardInterrupt

Note, this wiki has some weird webserver configuration which causes several problems. Apparently, api.php returns the HTML main page if you attempt to POST any data instead of POSTing the API parameters as URL parameters. I'm not sure that's the culprit though.

From https://github.com/WikiTeam/wikiteam/issues/314

nemobis commented 4 years ago

Same in a MediaWiki 1.34 wiki:

Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wikitools
>>> site = wikitools.wiki.Wiki("http://luz.izt.uam.mx/wikis/mediawiki/api.php")
Invalid JSON, trying request again
Invalid JSON, trying request again
Invalid JSON, trying request again
Invalid JSON, trying request again
HTTPError: HTTP Error 301: The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
Moved Permanently trying request again in 5 seconds
HTTPError: HTTP Error 301: The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
Moved Permanently trying request again in 10 seconds
HTTPError: HTTP Error 301: The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
Moved Permanently trying request again in 15 seconds