From ed32b9f7f41cf3e01a51078420434be93a374ba0 Mon Sep 17 00:00:00 2001 From: Thorsten Date: Sat, 14 Mar 2026 19:12:41 +0100 Subject: [PATCH] add User-Agent header to Wikipedia API requests --- src/distbot/plugins/lookup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/distbot/plugins/lookup.py b/src/distbot/plugins/lookup.py index 547b762..f412231 100644 --- a/src/distbot/plugins/lookup.py +++ b/src/distbot/plugins/lookup.py @@ -131,11 +131,12 @@ class Wikipedia(Worker): 'inprop': 'url' } apiurl = 'https://%s.wikipedia.org/w/api.php' % (lang) + headers = {'User-Agent': 'urlbot-v3/1.0 (XMPP bot)'} logger.info('fetching %s' % apiurl) try: - response = requests.get(apiurl, params=apiparams).json() + response = requests.get(apiurl, params=apiparams, headers=headers).json() page = next(iter(response['query']['pages'].values())) short = page.get('extract') -- 2.47.3