Fix handling of Content-Disposition headers

This commit is contained in:
Klaus-Uwe Mitterer 2017-09-10 21:59:43 +02:00
parent a8f3d43c82
commit 3ed2669c9d

View file

@ -59,7 +59,7 @@ def pageHandler(driver):
fid = a["href"].split("=")[1]
if not glob.glob("files/sbd%s*" % fid):
res = session.get("https://scriptzbase.org/%s" % a["href"])
fname = re.findall("filename=(.+)", res.headers["content-disposition"])[0].strip('"')
fname = re.findall("filename=(.+)", res.headers["content-disposition"])[0].split(";")[0].strip('"')
with open("files/sbd%s_%s" % (fid, fname), "wb") as out:
out.write(res.content)