We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Some wikipedia pages (such as Serbian and Chinese) have multiple language variants that are equivalent.
Fetching the content is then dependent on the variant variable in the API: https://zh.wikipedia.org/wiki/Special:API%E6%B2%99%E7%9B%92?uselang=en#action=parse&format=json&variant=zh-tw&page=Main%20Page&formatversion=2
I'm currently working around this by monkey-patching the wikipediaapi.Wikipedia._query method like this:
wikipediaapi.Wikipedia._query
def patched_query(self, page: "WikipediaPage", params: dict[str, Any]): """Queries Wikimedia API to fetch content.""" print(self._request_kwargs) if 'variant' in self._request_kwargs: params['variant'] = self._request_kwargs['variant'] del(self._request_kwargs['variant']) base_url = "https://" + page.language + ".wikipedia.org/w/api.php" #log.info( # "Request URL: %s", # base_url + "?" + "&".join([k + "=" + str(v) for k, v in params.items()]) #) params["format"] = "json" params["redirects"] = 1 print(params) r = self._session.get(base_url, params=params, **self._request_kwargs) return r.json()
Ideally there would be a way to specify extra params that go to the wikipedia call, not just to the request library.
The text was updated successfully, but these errors were encountered:
This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Sorry, something went wrong.
This issue was closed because it has been stalled for 10 days with no activity.
No branches or pull requests
Some wikipedia pages (such as Serbian and Chinese) have multiple language variants that are equivalent.
Fetching the content is then dependent on the variant variable in the API: https://zh.wikipedia.org/wiki/Special:API%E6%B2%99%E7%9B%92?uselang=en#action=parse&format=json&variant=zh-tw&page=Main%20Page&formatversion=2
I'm currently working around this by monkey-patching the
wikipediaapi.Wikipedia._query
method like this:Ideally there would be a way to specify extra params that go to the wikipedia call, not just to the request library.
The text was updated successfully, but these errors were encountered: