|
@@ -134,7 +134,7 @@ def download_img(load_data, target_file_path):
|
|
|
cursor = conn.cursor()
|
|
cursor = conn.cursor()
|
|
|
|
|
|
|
|
print('正在下载图片')
|
|
print('正在下载图片')
|
|
|
- for data in load_data:
|
|
|
|
|
|
|
+ for index, data in enumerate(load_data):
|
|
|
# 如果img文件存在, 即已经下载过, 直接跳过
|
|
# 如果img文件存在, 即已经下载过, 直接跳过
|
|
|
id = data['id']
|
|
id = data['id']
|
|
|
name = data['name']
|
|
name = data['name']
|
|
@@ -175,7 +175,9 @@ def download_img(load_data, target_file_path):
|
|
|
cursor.execute(query, (True, id))
|
|
cursor.execute(query, (True, id))
|
|
|
conn.commit()
|
|
conn.commit()
|
|
|
|
|
|
|
|
- # print(f'已下载:{img_name}')
|
|
|
|
|
|
|
+ # 算一下进度
|
|
|
|
|
+ rate = index / len(load_data) * 100
|
|
|
|
|
+ print(f'已下载:{img_name}, 当前第 {index} 个, 共 {len(load_data)} 个, 已下载 {rate:.2f}%')
|
|
|
time.sleep(random.uniform(1, 2))
|
|
time.sleep(random.uniform(1, 2))
|
|
|
break
|
|
break
|
|
|
except Exception as e:
|
|
except Exception as e:
|