mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-24 01:08:06 -06:00
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 <Chocobo1@users.noreply.github.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user