解决chrome quit的问题
This commit is contained in:
@@ -44,6 +44,8 @@ def download_image(url):
|
||||
|
||||
def fetch_and_create_pdf(url):
|
||||
"""根据给定URL抓取页面并生成PDF"""
|
||||
driver =None
|
||||
try:
|
||||
# 配置Selenium
|
||||
options = Options()
|
||||
options.add_argument('--headless') # 使用新的headless模式
|
||||
@@ -225,7 +227,13 @@ def fetch_and_create_pdf(url):
|
||||
driver.quit()
|
||||
# 如果生成失败,返回一个默认路径或空字符串
|
||||
return ""
|
||||
|
||||
except Exception as e:
|
||||
logger.info(f"抓取帖子时出错: {e}")
|
||||
# 如果抓取失败,返回一个默认路径或空字符串
|
||||
driver.quit()
|
||||
return ""
|
||||
finally:
|
||||
driver.quit()
|
||||
|
||||
# add_pdf_encryption 和 pdf_file_path 函数保持不变
|
||||
def add_pdf_encryption(pdf_file, password="4000"):
|
||||
|
||||
Reference in New Issue
Block a user