2.7 Update (future)
2.7 Update (future)
This commit is contained in:
commit
fb9c8201f5
@ -63,6 +63,17 @@ else:
|
||||
except:
|
||||
print('[-]Config.ini read failed! Please use the offical file!')
|
||||
|
||||
def get_network_settings():
|
||||
try:
|
||||
proxy = config["proxy"]["proxy"]
|
||||
timeout = int(config["proxy"]["timeout"])
|
||||
retry_count = int(config["proxy"]["retry"])
|
||||
assert timeout > 0
|
||||
assert retry_count > 0
|
||||
except:
|
||||
raise ValueError("[-]Proxy config error! Please check the config.")
|
||||
return proxy, timeout, retry_count
|
||||
|
||||
def getDataState(json_data): # 元数据获取失败检测
|
||||
if json_data['title'] == '' or json_data['title'] == 'None' or json_data['title'] == 'null':
|
||||
return 0
|
||||
@ -87,16 +98,11 @@ def getXpathSingle(htmlcode,xpath):
|
||||
return result1
|
||||
|
||||
def get_html(url,cookies = None):#网页请求核心
|
||||
try:
|
||||
proxy = config['proxy']['proxy']
|
||||
timeout = int(config['proxy']['timeout'])
|
||||
retry_count = int(config['proxy']['retry'])
|
||||
except:
|
||||
print('[-]Proxy config error! Please check the config.')
|
||||
proxy, timeout, retry_count = get_network_settings()
|
||||
i = 0
|
||||
while i < retry_count:
|
||||
try:
|
||||
if not str(config['proxy']['proxy']) == '':
|
||||
if not proxy == '':
|
||||
proxies = {"http": "http://" + proxy,"https": "https://" + proxy}
|
||||
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3100.0 Safari/537.36'}
|
||||
getweb = requests.get(str(url), headers=headers, timeout=timeout,proxies=proxies, cookies=cookies)
|
||||
|
@ -5,8 +5,11 @@ success_output_folder=JAV_output
|
||||
soft_link=0
|
||||
|
||||
[proxy]
|
||||
# modify this line to your proxy server, leave black proxy= for direct connection
|
||||
proxy=127.0.0.1:1081
|
||||
# timeout must always be greater than zero
|
||||
timeout=10
|
||||
# retry must always be greater than zero
|
||||
retry=3
|
||||
|
||||
[Name_Rule]
|
||||
@ -25,4 +28,4 @@ literals=\()
|
||||
folders=failed,JAV_output
|
||||
|
||||
[debug_mode]
|
||||
switch=0
|
||||
switch=0
|
||||
|
10
core.py
10
core.py
@ -212,15 +212,7 @@ def creatFolder(success_folder, location_rule, json_data, Config): # 创建文
|
||||
|
||||
# =====================资源下载部分===========================
|
||||
def DownloadFileWithFilename(url, filename, path, Config, filepath, failed_folder): # path = examle:photo , video.in the Project Folder!
|
||||
retry_count = 0
|
||||
proxy = ''
|
||||
timeout = 0
|
||||
try:
|
||||
proxy = Config['proxy']['proxy']
|
||||
timeout = int(Config['proxy']['timeout'])
|
||||
retry_count = int(Config['proxy']['retry'])
|
||||
except:
|
||||
print('[-]Proxy config error! Please check the config.')
|
||||
proxy, timeout, retry_count = get_network_settings()
|
||||
i = 0
|
||||
|
||||
while i < retry_count:
|
||||
|
10
core2.py
10
core2.py
@ -207,15 +207,7 @@ def creatFolder(success_folder, location_rule, json_data, Config): # 创建文
|
||||
|
||||
# =====================资源下载部分===========================
|
||||
def DownloadFileWithFilename(url, filename, path, Config, filepath, failed_folder): # path = examle:photo , video.in the Project Folder!
|
||||
retry_count = 0
|
||||
proxy = ''
|
||||
timeout = 0
|
||||
try:
|
||||
proxy = Config['proxy']['proxy']
|
||||
timeout = int(Config['proxy']['timeout'])
|
||||
retry_count = int(Config['proxy']['retry'])
|
||||
except:
|
||||
print('[-]Proxy config error! Please check the config.')
|
||||
proxy, timeout, retry_count = get_network_settings()
|
||||
i = 0
|
||||
|
||||
while i < retry_count:
|
||||
|
Loading…
Reference in New Issue
Block a user