From e60e96cb0ee4b39ff7554cf6e2da7d826e282df7 Mon Sep 17 00:00:00 2001 From: BurningMop Date: Sun, 9 Jun 2024 03:03:39 -0300 Subject: [PATCH] Add optional headers to search request PR #20923. --- src/searchengine/nova3/helpers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/searchengine/nova3/helpers.py b/src/searchengine/nova3/helpers.py index d453f1c4d..0aaf281b2 100644 --- a/src/searchengine/nova3/helpers.py +++ b/src/searchengine/nova3/helpers.py @@ -1,4 +1,4 @@ -#VERSION: 1.45 +#VERSION: 1.46 # Author: # Christophe DUMEZ (chris@qbittorrent.org) @@ -87,9 +87,9 @@ def htmlentitydecode(s): return re.sub(r'&#x(\w+);', lambda x: chr(int(x.group(1), 16)), t) -def retrieve_url(url): +def retrieve_url(url, custom_headers={}): """ Return the content of the url page as a string """ - req = urllib.request.Request(url, headers=headers) + req = urllib.request.Request(url, headers={**headers, **custom_headers}) try: response = urllib.request.urlopen(req) except urllib.error.URLError as errno: