mirror of
https://github.com/JoeanAmier/XHS-Downloader.git
synced 2025-12-26 04:48:05 +08:00
更新代码
This commit is contained in:
parent
5fd3358ed9
commit
5a755a4b95
@ -4,24 +4,33 @@ from requests import get
|
||||
|
||||
class Html:
|
||||
|
||||
def __init__(self, headers: dict):
|
||||
def __init__(
|
||||
self,
|
||||
headers: dict,
|
||||
proxies=None,
|
||||
timeout=10, ):
|
||||
self.headers = headers
|
||||
self.proxies = {
|
||||
"http": proxies,
|
||||
"https": proxies,
|
||||
"ftp": proxies,
|
||||
}
|
||||
self.timeout = timeout
|
||||
|
||||
def get_html(
|
||||
self,
|
||||
url: str,
|
||||
params=None,
|
||||
proxies=None,
|
||||
timeout=10,
|
||||
**kwargs) -> str:
|
||||
headers=None,
|
||||
allow_redirects=True) -> str:
|
||||
try:
|
||||
response = get(
|
||||
url,
|
||||
params=params,
|
||||
proxies=proxies,
|
||||
timeout=timeout,
|
||||
headers=self.headers,
|
||||
**kwargs)
|
||||
proxies=self.proxies,
|
||||
timeout=self.timeout,
|
||||
headers=headers or self.headers,
|
||||
allow_redirects=allow_redirects, )
|
||||
except (
|
||||
requests.exceptions.ProxyError,
|
||||
requests.exceptions.SSLError,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user