From efdc4af448755f18413b634155d932e82b600c41 Mon Sep 17 00:00:00 2001 From: ducalex Date: Sat, 17 Aug 2024 01:32:57 -0400 Subject: [PATCH] Search helpers: Add POST support to `retrieve_url` This allows passing request_data to retrieve_url in order to create a post request. PR #21184. --------- Co-authored-by: Chocobo1 --- 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 60c4370e9..ef8376a28 100644 --- a/src/searchengine/nova3/helpers.py +++ b/src/searchengine/nova3/helpers.py @@ -1,4 +1,4 @@ -#VERSION: 1.48 +#VERSION: 1.49 # Author: # Christophe DUMEZ (chris@qbittorrent.org) @@ -89,10 +89,10 @@ def htmlentitydecode(s: str) -> str: return re.sub(r'&#x(\w+);', lambda x: chr(int(x.group(1), 16)), t) -def retrieve_url(url: str, custom_headers: Mapping[str, Any] = {}) -> str: +def retrieve_url(url: str, custom_headers: Mapping[str, Any] = {}, request_data: Optional[Any] = None) -> str: """ Return the content of the url page as a string """ - request = urllib.request.Request(url, headers={**headers, **custom_headers}) + request = urllib.request.Request(url, request_data, {**headers, **custom_headers}) try: response = urllib.request.urlopen(request) except urllib.error.URLError as errno: