|
@@ -2,10 +2,12 @@ import os.path
|
|
|
import re
|
|
import re
|
|
|
import random
|
|
import random
|
|
|
import time
|
|
import time
|
|
|
-
|
|
|
|
|
import httpx
|
|
import httpx
|
|
|
|
|
|
|
|
-url_key = 'UHh0dkRPOWwyV2R2V0ZFU3hMRFZaZz09.html?'
|
|
|
|
|
|
|
+url_keys = [
|
|
|
|
|
+ 'L2lBQ200aE0vOVNmUGcydzhhT296Zz09',
|
|
|
|
|
+ 'RFFRQXFIZEhNeDNaV2txWjRlMk5xdz09'
|
|
|
|
|
+]
|
|
|
url_photos = '/photos/'
|
|
url_photos = '/photos/'
|
|
|
base_url = 'https://www.kaizty.com/'
|
|
base_url = 'https://www.kaizty.com/'
|
|
|
url_page = 'page={}'
|
|
url_page = 'page={}'
|
|
@@ -15,7 +17,7 @@ headers = {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-def get_pages():
|
|
|
|
|
|
|
+def get_pages(url_key):
|
|
|
title = ''
|
|
title = ''
|
|
|
all_img_list = []
|
|
all_img_list = []
|
|
|
|
|
|
|
@@ -54,7 +56,7 @@ def get_pages():
|
|
|
error_times += 1
|
|
error_times += 1
|
|
|
continue
|
|
continue
|
|
|
all_img_list += img_list
|
|
all_img_list += img_list
|
|
|
- # time.sleep(random.uniform(2, 3))
|
|
|
|
|
|
|
+ time.sleep(random.uniform(2, 3))
|
|
|
|
|
|
|
|
return all_img_list, title
|
|
return all_img_list, title
|
|
|
|
|
|
|
@@ -85,21 +87,23 @@ def get_imgs(all_img_list, title):
|
|
|
print('正在保存图片: {}'.format(file_name))
|
|
print('正在保存图片: {}'.format(file_name))
|
|
|
with open(title + "/" + file_name, "wb") as f:
|
|
with open(title + "/" + file_name, "wb") as f:
|
|
|
f.write(img.content)
|
|
f.write(img.content)
|
|
|
- # time.sleep(random.uniform(8, 10))
|
|
|
|
|
|
|
+ time.sleep(random.uniform(5, 8))
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
- all_img_list, title = get_pages()
|
|
|
|
|
-
|
|
|
|
|
- while True:
|
|
|
|
|
- try:
|
|
|
|
|
- get_imgs(all_img_list, title)
|
|
|
|
|
- except Exception as e:
|
|
|
|
|
- print(e)
|
|
|
|
|
- time.sleep(random.uniform(30, 40))
|
|
|
|
|
- continue
|
|
|
|
|
- else:
|
|
|
|
|
- print("程序执行完成,退出循环")
|
|
|
|
|
- break
|
|
|
|
|
|
|
+ for url_key in url_keys:
|
|
|
|
|
+ url_key = url_key + '.html?'
|
|
|
|
|
+ all_img_list, title = get_pages(url_key)
|
|
|
|
|
+
|
|
|
|
|
+ while True:
|
|
|
|
|
+ try:
|
|
|
|
|
+ get_imgs(all_img_list, title)
|
|
|
|
|
+ except Exception as e:
|
|
|
|
|
+ print(e)
|
|
|
|
|
+ time.sleep(random.uniform(30, 40))
|
|
|
|
|
+ continue
|
|
|
|
|
+ else:
|
|
|
|
|
+ print("图片保存完成,退出循环")
|
|
|
|
|
+ break
|
|
|
|
|
|
|
|
print("done")
|
|
print("done")
|