From aa75d55d85b550de38c001b053ba52eb35f50a04 Mon Sep 17 00:00:00 2001 From: liuwei Date: Thu, 27 Mar 2025 16:55:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8F=92=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E7=94=A8=E6=AF=8F=E6=AC=A1=E9=83=BD=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiuren/meitu_dl.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/xiuren/meitu_dl.py b/xiuren/meitu_dl.py index 2b54637..73938fd 100644 --- a/xiuren/meitu_dl.py +++ b/xiuren/meitu_dl.py @@ -85,7 +85,18 @@ def fetch_images(post_url): options = Options() options.headless = True - driver = webdriver.Chrome(options=options) + + # 使用本地固定的ChromeDriver路径,避免每次自动更新 + chrome_driver_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "chromedriver.exe") + + # 如果本地没有chromedriver.exe,则使用默认方式 + if not os.path.exists(chrome_driver_path): + driver = webdriver.Chrome(options=options) + print("使用默认ChromeDriver") + else: + from selenium.webdriver.chrome.service import Service + driver = webdriver.Chrome(service=Service(chrome_driver_path), options=options) + print(f"使用本地ChromeDriver: {chrome_driver_path}") for page in range(1, total_pages + 1): url = f"{post_url}/{page}" if page > 1 else post_url