fix(wiki_article): correct URL escaping for title

Corrected the URL escaping for titles in `wiki_article` function by setting `escape` flag to `False`. This ensures the correct handling of titles with special characters. Resolves potential issues with fetching article content due to over-escaping.
This commit is contained in:
Kumi 2024-08-18 11:22:19 +02:00
parent c4e7acdae4
commit b7ba63688d
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -119,7 +119,7 @@ def wiki_article(project, lang, title):
logger.debug(f"Fetching {title} from {base_url}") logger.debug(f"Fetching {title} from {base_url}")
url = f"{base_url}/w/api.php?action=query&format=json&titles={escape(title.replace(' ', '_'), True)}&prop=revisions&rvprop=content&rvparse=1" url = f"{base_url}/w/api.php?action=query&format=json&titles={escape(title.replace(' ', '_'), False)}&prop=revisions&rvprop=content&rvparse=1"
with urllib.request.urlopen(url) as response: with urllib.request.urlopen(url) as response:
data = json.loads(response.read().decode()) data = json.loads(response.read().decode())
pages = data["query"]["pages"] pages = data["query"]["pages"]