批量pdf下载
2021-07-01 本文已影响0人
月夜星空下
import requests
file_read = open("创业板:年报_半年报_问询函.txt", encoding='utf-8')
i = 0
while True:
try:
text = file_read.readline()
text = text.replace('\n','')
if len(text) > 2:
url = 'http://reportdocs.static.szse.cn/UpFiles/fxklwxhj/{}?random=0.42680171432249325'.format(text)
res = requests.get(url)
res.encoding = res.apparent_encoding
file_path = r'\\192.168.1.23\tools\创业板:年报_半年报_问询函' + '\\'
dir = file_path + text
with open(dir, 'wb') as f:
f.write(res.content)
i += 1
print('successful', i)
except Exception as e:
print(e)
pass