python2 通过url解压zip文件
import zipfile
import StringIO
import requests
# 通过url获取zip文件
r = requests.get(url, stream=True)
z = zipfile.ZipFile(StringIO.StringIO(r.content))
# 解压到指定文件夹
z.extractall(path=path)
file_list = os.listdir(path)
for file_name in file_list:
if '.pdf' in file_name:
file_path = os.path.join(path, file_name)
with open(file_path, 'r') as f:
file_data = f.read()