标签:log txt 需要 name while color article 批量下载 批量
最近项目需要将批量链接中的pdf文档爬下来处理,根据以下步骤完成了任务:
参考资料:
1 import urllib.request 2 import os 3 4 def getFile(url): 5 file_name = url.split(‘/‘)[-1] 6 u = urllib.request.urlopen(url) 7 f = open(file_name, ‘wb‘) 8 block_sz = 8192 9 while True: 10 buffer = u.read(block_sz) 11 if not buffer: 12 break 13 f.write(buffer) 14 f.close() 15 print("Sucessful to download" + " " + file_name) 16 17 os.chdir(os.path.join(os.getcwd(), ‘pdf_download‘)) 18 19 f=open(‘E:/VGID_Text/url_list.txt‘) 20 url_list=f.readlines() 21 url_lst=[] 22 for line in url_list: 23 line=line.rstrip("\n") 24 getFile(line)
标签:log txt 需要 name while color article 批量下载 批量
原文地址:https://www.cnblogs.com/wind-chaser/p/10514449.html