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

Json error with get_query() #177

Open
jheinecke opened this issue Apr 25, 2023 · 0 comments
Open

Json error with get_query() #177

jheinecke opened this issue Apr 25, 2023 · 0 comments

Comments

@jheinecke
Copy link

I stumbled across a problem:

p = wptools.page("Arabic")
gq = p.get_query()

which crashes due to a continue problem:

<wptools.page.WPToolsPage object at 0x7f0887ff9760>
en.wikipedia.org (query) Arabic
en.wikipedia.org (query) Arabic (&plcontinue=803|0|Kanuri_language)
en.wikipedia.org (query) Arabic (&plcontinue=803|0|ء)
Traceback (most recent call last):
  File "/home/johannes/.local/lib/python3.8/site-packages/wptools/core.py", line 199, in _load_response
    data = utils.json_loads(response)
  File "/home/johannes/.local/lib/python3.8/site-packages/wptools/utils.py", line 95, in json_loads
    return json.loads(data, encoding='utf-8')
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./t.py", line 23, in <module>
    tt('Arabic')
  File "./t.py", line 12, in tt
    gq = p.get_query()
  File "/home/johannes/.local/lib/python3.8/site-packages/wptools/page.py", line 641, in get_query
    self._get('query', show, proxy, timeout)
  File "/home/johannes/.local/lib/python3.8/site-packages/wptools/core.py", line 183, in _get
    self._set_data(action)
  File "/home/johannes/.local/lib/python3.8/site-packages/wptools/page.py", line 200, in _set_data
    self._set_query_data(action)
  File "/home/johannes/.local/lib/python3.8/site-packages/wptools/page.py", line 295, in _set_query_data
    data = self._load_response(action)
  File "/home/johannes/.local/lib/python3.8/site-packages/wptools/core.py", line 201, in _load_response
    raise ValueError(_query)
ValueError: https://en.wikipedia.org/w/api.php?action=query&exintro&formatversion=2&inprop=url|watchers&list=random&pithumbsize=240&pllimit=500&ppprop=disambiguation|wikibase_item&prop=extracts|info|links|pageassessments|pageimages|pageprops|pageterms|redirects&redirects&rdlimit=500&rnlimit=1&rnnamespace=0&titles=Arabic&plcontinue=803|0|ء

Most wikipedia pages work well, but I came across a few which produce this error

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

1 participant