From 0df4c8a20f156801c691a990f137bab7b5dc66dc Mon Sep 17 00:00:00 2001 From: zkep <773683464@qq.com> Date: Sun, 23 Feb 2025 09:30:57 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8Bgeektime=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compress.py | 5 +++++ main.py | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/compress.py b/compress.py index f21838939d..592ed9b12f 100644 --- a/compress.py +++ b/compress.py @@ -11,6 +11,11 @@ def compress(source: str, target: str, power: int = 0): :param str source: source PDF file :param str target: target location to save the compressed PDF :param int power: power of the compression. Default value is 0. This can be 0: default, 1: prepress, 2: printer, 3: ebook, 4: screen + screen 低画质 + ebook 中等画质 + printer 打印机画质 + prepress 最大画质 + defaul 默认画质 """ quality = { diff --git a/main.py b/main.py index 90657ea654..dce9398893 100644 --- a/main.py +++ b/main.py @@ -179,8 +179,7 @@ def make_all_pdf(source, output, timeout, compress, power, port): webdriver_options.add_experimental_option("prefs", webdriver_prefs) webdriver_options.add_experimental_option("excludeSwitches", ['enable-automation']) - http_client = requests.Session() - download_manager = WDMDownloadManager(http_client=http_client) + download_manager = WDMDownloadManager(http_client=reqsession) service = Service(ChromeDriverManager(download_manager=download_manager).install()) host = f"http://127.0.0.1:{port}/" for dirname, _, file_lst in os.walk(source): @@ -399,8 +398,7 @@ def make_pdf(source, output, timeout, compress, power, port): webdriver_options.add_argument("--disable-dev-shm-usage") webdriver_options.experimental_options["prefs"] = webdriver_prefs - http_client = requests.Session() - download_manager = WDMDownloadManager(http_client=http_client) + download_manager = WDMDownloadManager(http_client=reqsession) service = Service(ChromeDriverManager(download_manager=download_manager).install()) host = f"http://127.0.0.1:{port}/" source = os.path.abspath(source)