parent
29dace50f4
commit
81e165e515
4 changed files with 116 additions and 27 deletions
@ -1 +1 @@ |
||||
Hm_lvt_7a3960b6f067eb0085b7f96ff5e660b0=1690080220,1690550836,1690723621,1690809059; ndut_fmt=2F3F7209152B005542DB9E27E1FE8B25A229DCC706598E1B99139109B3AD5791; BDCLND=Kiz1b8Bpv31XBFDJNdGFjZSNEpvCREEMgiHA5oAF99k%3D; BDUSS=3dlMEhZLWtLS2tGeVh2T1ozYWtYaXdFTWV6QnRrYzByMEwzd2hWWmxkamd4dk5pRVFBQUFBJCQAAAAAAAAAAAEAAADgajfycm9nZXJzdW4wOTAxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOA5zGLgOcxid; BIDUPSID=2947C9BCCF77B5D4BFC420C602BE3DF5; PSTM=1658846657; ZFY=0Vc50oTr7EmlM6WxzWE2Eewo0ltT5VQJ2KG9s8DcdoY:C; MCITY=-131%3A; STOKEN=d598c65d443486ba06db34f988e6ac8d108c6b2e4f4eae47aeec796b8c487453; BAIDUID=8DC7F291FA0638DF89C98F0178FCDC7C:FG=1; BAIDUID_BFESS=8DC7F291FA0638DF89C98F0178FCDC7C:FG=1; PANWEB=1; newlogin=1; csrfToken=2r7JSCtVulGN3eOExz3JqsxP; PANPSC=12925419710669722059%3AKkwrx6t0uHBNjb%2BA%2BPLlBZgtJeEFa7WQw1jWL8y1tqu8ztnSQmWL1wZuq6kOUHWChFbm%2BExtunGiz1cJOClRr8ZIzuhpmLh6b55KeZe4CQBn3K3RJ8ZwedL9vR6DsgcTu1tPRVPr6y7%2FwyO%2B4eG7s0I0NZhR03fFuueAr2t%2FRhNXpcvfoZtUp%2B4PuTzNr1rr; ab_sr=1.0.1_NDE5NTY0NjYxYjNjZmVjZmQ2YTY1YjYzMjFlY2E5MGViZWI2MWY5MzA1Yzk4N2M1YzM3YmFlZmM2MmM1NmNmYjgzYTk4NWQxNzdiZWQxZTAzN2RlYjQ2NmI1NjAzNTAwNmJjNjNlZGFkN2JmNTUxNDMzNmRkM2RkZWVhZTZhMTM4ZjA3ZjJlMTAxYTc2MTk2YmM0YTA5OGUzMWIzNzE5Yjg0MTFkNzdjOThhMjA5ZDVhODczOTZiYzM2ZmEzZjhk |
||||
Hm_lvt_7a3960b6f067eb0085b7f96ff5e660b0=1690550836,1690723621,1690809059,1691281792; ndut_fmt=08603C41725B9D1E463435C4C64207479195C09D833C50A24353D22EB2E4456E; BDCLND=mZG1nNwbvm0KuvJr0nMrsqnZaPHR9lfsfkzVrAx5mig%3D; BDUSS=3dlMEhZLWtLS2tGeVh2T1ozYWtYaXdFTWV6QnRrYzByMEwzd2hWWmxkamd4dk5pRVFBQUFBJCQAAAAAAAAAAAEAAADgajfycm9nZXJzdW4wOTAxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOA5zGLgOcxid; BIDUPSID=2947C9BCCF77B5D4BFC420C602BE3DF5; PSTM=1658846657; ZFY=0Vc50oTr7EmlM6WxzWE2Eewo0ltT5VQJ2KG9s8DcdoY:C; MCITY=-131%3A; STOKEN=d598c65d443486ba06db34f988e6ac8d108c6b2e4f4eae47aeec796b8c487453; BAIDUID=8DC7F291FA0638DF89C98F0178FCDC7C:FG=1; BAIDUID_BFESS=8DC7F291FA0638DF89C98F0178FCDC7C:FG=1; PANWEB=1; newlogin=1; csrfToken=1xjPBP_dJWHgaoiwR4nQ7VBL; PANPSC=12489461165957612349%3AKkwrx6t0uHBNjb%2BA%2BPLlBZgtJeEFa7WQw1jWL8y1tqu8ztnSQmWL1wZuq6kOUHWCO5C65PtcmdJbCWSrkiaxSMZIzuhpmLh6b55KeZe4CQBn3K3RJ8ZwedL9vR6DsgcTu1tPRVPr6y7%2FwyO%2B4eG7s0I0NZhR03fF1bSRWp4nHGroivDAyr3Yne4PuTzNr1rr; ab_sr=1.0.1_NTI5MWQ4OGQ2ZTcwMTM0ZTgzZDQ5YzEzZjc5NmJlMWMxOGVjODEyOGM1ZWFlZGRkMDc1YzRiYjE3OGVjOWFlOWFkNmViNzVlMzU0YmM0YmFmM2EyNWViZWFhY2U4MWEyOTdiOWM2NGRlOTE5OWUyZWI2NGNmYTE3YmE0OTFkZTUxYjQ0YmQ1Mjk5Njk1NGZlMWI5Mzg3Y2Y0OWZhZTE0NDQ0YzBkYjE4NWNiM2Y2YTVjZGZmZjhlYjExOTAzZTY2; Hm_lpvt_7a3960b6f067eb0085b7f96ff5e660b0=1691281801; Hm_lvt_fa0277816200010a74ab7d2895df481b=1691281797; Hm_lpvt_fa0277816200010a74ab7d2895df481b=1691281797 |
@ -0,0 +1,70 @@ |
||||
from db import DbAction |
||||
from req import ReqAction |
||||
from time import sleep |
||||
import random |
||||
|
||||
# config |
||||
# get_end_date = 'today' |
||||
get_end_date = '2023-08-03' |
||||
|
||||
|
||||
def format_link(link): |
||||
if '?pwd=' in link: |
||||
link = link[:-9] |
||||
if 'init?surl=' in link: |
||||
link = 'https://pan.baidu.com/s/1' + link[38:60] |
||||
return link |
||||
|
||||
|
||||
def req(_data, req_obj, db_obj): |
||||
base_temp_path = r'/Temp/' |
||||
save_path = [base_temp_path, _data['cate'] + r'/', str(_data['id'])] |
||||
print('-' * 30 + str(_data['id']) + '-' * 30) |
||||
print(save_path) |
||||
link = format_link(_data['save_link']) |
||||
print(_data['save_link'], ' -> ', link, ' ', _data['code']) |
||||
result, name = req_obj.process(save_path, link, _data['code']) |
||||
if result: |
||||
db_obj.update_file_name(_data['id'], name) |
||||
print(f'{_data["id"]}保存成功' + '\n' * 2) |
||||
return True |
||||
else: |
||||
print(f'{_data["id"]}保存失败,请检查!' + '\n' * 2) |
||||
return _data |
||||
|
||||
|
||||
def main(): |
||||
db_obj = DbAction(get_end_date) |
||||
req_obj = ReqAction() |
||||
try: |
||||
data_list = db_obj.get_db_data() |
||||
failed_list = [] |
||||
req_obj.prepare() |
||||
for _data in data_list: |
||||
result = req(_data, req_obj, db_obj) |
||||
if isinstance(result, dict): |
||||
failed_list.append(result) |
||||
sleep(random.randint(0, 3) + random.random()) |
||||
i = 3 |
||||
while len(failed_list) > 0 and i > 0: |
||||
_temp_list = [] |
||||
for _data in failed_list: |
||||
result = req(_data, req_obj, db_obj) |
||||
if isinstance(result, dict): |
||||
_temp_list.append(result) |
||||
sleep(random.randint(0, 3) + random.random()) |
||||
failed_list = _temp_list |
||||
i -= 1 |
||||
|
||||
if len(failed_list): |
||||
failed_id = [_data['id'] for _data in failed_list] |
||||
print('重试后依然失败:') |
||||
print(failed_id) |
||||
except Exception as e: |
||||
print(e) |
||||
finally: |
||||
db_obj.disconnect_db() |
||||
|
||||
|
||||
if __name__ == '__main__': |
||||
main() |
Loading…
Reference in new issue