Add proxy certificate
This commit is contained in:
@@ -40,6 +40,7 @@ def get_proxy(proxy: str, proxytype: str = None) -> dict:
|
|||||||
|
|
||||||
# 网页请求核心
|
# 网页请求核心
|
||||||
def get_html(url, cookies: dict = None, ua: str = None, return_type: str = None):
|
def get_html(url, cookies: dict = None, ua: str = None, return_type: str = None):
|
||||||
|
verify=config.Config().cacert_file()
|
||||||
switch, proxy, timeout, retry_count, proxytype = config.Config().proxy()
|
switch, proxy, timeout, retry_count, proxytype = config.Config().proxy()
|
||||||
proxies = get_proxy(proxy, proxytype)
|
proxies = get_proxy(proxy, proxytype)
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ def get_html(url, cookies: dict = None, ua: str = None, return_type: str = None)
|
|||||||
for i in range(retry_count):
|
for i in range(retry_count):
|
||||||
try:
|
try:
|
||||||
if switch == '1' or switch == 1:
|
if switch == '1' or switch == 1:
|
||||||
result = requests.get(str(url), headers=headers, timeout=timeout, proxies=proxies, cookies=cookies)
|
result = requests.get(str(url), headers=headers, timeout=timeout, proxies=proxies, verify=verify, cookies=cookies)
|
||||||
else:
|
else:
|
||||||
result = requests.get(str(url), headers=headers, timeout=timeout, cookies=cookies)
|
result = requests.get(str(url), headers=headers, timeout=timeout, cookies=cookies)
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ type=http
|
|||||||
proxy=127.0.0.1:1080
|
proxy=127.0.0.1:1080
|
||||||
timeout=5
|
timeout=5
|
||||||
retry=3
|
retry=3
|
||||||
|
cacert_file=
|
||||||
|
|
||||||
[Name_Rule]
|
[Name_Rule]
|
||||||
location_rule=actor+'/'+number
|
location_rule=actor+'/'+number
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ class Config:
|
|||||||
return switch, proxy, timeout, retry, proxytype
|
return switch, proxy, timeout, retry, proxytype
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self._exit("common")
|
self._exit("common")
|
||||||
|
|
||||||
|
def cacert_file(self) -> str:
|
||||||
|
return self.conf.get('proxy', 'cacert_file')
|
||||||
|
|
||||||
def media_type(self) -> str:
|
def media_type(self) -> str:
|
||||||
return self.conf.get('media', 'media_type')
|
return self.conf.get('media', 'media_type')
|
||||||
@@ -153,6 +156,8 @@ class Config:
|
|||||||
conf.set(sec2, "timeout", "5")
|
conf.set(sec2, "timeout", "5")
|
||||||
conf.set(sec2, "retry", "3")
|
conf.set(sec2, "retry", "3")
|
||||||
conf.set(sec2, "type", "socks5")
|
conf.set(sec2, "type", "socks5")
|
||||||
|
conf.set(sec2, "cacert_file", "")
|
||||||
|
|
||||||
|
|
||||||
sec3 = "Name_Rule"
|
sec3 = "Name_Rule"
|
||||||
conf.add_section(sec3)
|
conf.add_section(sec3)
|
||||||
|
|||||||
Reference in New Issue
Block a user