[Python] 纯文本查看 复制代码
from time import perf_counter
import requests
import multiprocessing
def RequestsDX(url):
headers = {
'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/86.0.4240.111 Safari/537.36 Edg/86.0.622.51',
'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,'
'application/'
'signed-exchange;v=b3;q=0.9'
}
response = requests.get(url=url, headers=headers)
response.encoding = 'utf-8'
return response
def down_load(download_list): # 开始下载
response = RequestsDX(download_list[1])
print('=' * 100)
print('正在下载', download_list[0])
with open(r'D:\ppt\%s.zip' % download_list[0], 'wb') as f :
for chunk in response.iter_content(chunk_size=1024) :
f.write(chunk)
print('下载完成')
if __name__ == '__main__':
download_list = [
('通用工作述职汇报PPT模板', 'http://www.youpinppt.com/soft/201013/1-201013195921.zip'),
('大气黑灰工作述职报告PPT模板', 'http://www.youpinppt.com/soft/200905/1-200Z5205113.zip'),
('新员工转正述职报告PPT模板', 'http://www.youpinppt.com/soft/200816/1-200Q6052914.zip'),
('炫彩烟雾水彩总结述职PPT模板', 'http://www.youpinppt.com/soft/200707/1-200FH33044.zip'),
('极简试用期转正述职报告PPT模板', 'http://www.youpinppt.com/soft/200623/1-200623103147.zip'),
('极简工作述职报告PPT模板', 'http://www.youpinppt.com/soft/200528/1-20052Q11T6.zip'),
('极简述职工作报告PPT模板', 'http://www.youpinppt.com/soft/200426/1-200426210042.zip'),
('办公桌面述职报告PPT模板', 'http://www.youpinppt.com/soft/200331/1-200331100H5.zip'),
('大气实用述职报告PPT模板', 'http://www.youpinppt.com/soft/200316/1-200316055252.zip'),
('立体岗位竞聘述职报告PPT模板', 'http://www.youpinppt.com/soft/200206/1-200206152Q2.rar'),
('蓝绿渐变述职报告PPT模板', 'http://www.youpinppt.com/soft/190725/1-1ZH5093211.rar'),
('淡雅朦胧述职报告PPT模板', 'http://www.youpinppt.com/soft/190326/1-1Z326091335.rar'),
('箭头通用述职报告PPT模板', 'http://www.youpinppt.com/soft/180823/1-1PR30Z355.rar'),
('简约三角风述职报告PPT模板', 'http://www.youpinppt.com/soft/180802/1-1PP2091F0.rar'),
('大气山峰述职报告PPT模板', 'http://www.youpinppt.com/soft/180724/1-1PH4235446.rar'),
('简约通用述职报告PPT模板', 'http://www.youpinppt.com/soft/180419/1-1P41Z92J5.rar'),
('简约蓝色述职报告PPT模板', 'http://www.youpinppt.com/soft/180112/1-1P112100122.rar'),
('简约大气工作述职报告PPT模板', 'http://www.youpinppt.com/soft/171229/1-1G22ZU636.rar'),
('简约实用述职报告PPT模板', 'http://www.youpinppt.com/soft/171003/1-1G003101554.rar'),
('唯美小清新竞聘述职PPT模板', 'http://www.youpinppt.com/soft/170330/1-1F330031506.rar'),
('创意个人简历竞聘述职PPT模板', 'http://www.youpinppt.com/soft/170227/1-1F22F04025.rar')
]
t = perf_counter()
pool = multiprocessing.Pool(10)
for i in download_list:
pool.apply_async(down_load, (i,))
pool.close()
pool.join()
t1 = perf_counter()
cost = t1-t
print(cost,'s')