From 7ae5ec65419af2dd358b45527b8e798693aee303 Mon Sep 17 00:00:00 2001 From: g1879 Date: Fri, 18 Sep 2020 16:36:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96download()=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/session_page.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DrissionPage/session_page.py b/DrissionPage/session_page.py index 1bfe5ad..9f9ce4d 100644 --- a/DrissionPage/session_page.py +++ b/DrissionPage/session_page.py @@ -324,7 +324,8 @@ class SessionPage(object): # -------------------开始下载------------------- # 获取远程文件大小 - file_size = int(r.headers['Content-Length']) if 'Content-Length' in r.headers else None + content_length = tuple(x for x in r.headers if x.lower() == 'content-length') + file_size = int(r.headers[content_length]) if content_length else None downloaded_size, download_status = 0, False # 已下载文件大小和下载状态 try: with open(str(full_path), 'wb') as tmpFile: