mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 21:03:30 -07: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:
parent
0535993e41
commit
efdc4af448
1 changed files with 3 additions and 3 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue