sehuatang pdf 优化

This commit is contained in:
liuwei
2025-12-25 13:29:25 +08:00
parent 9381824cb2
commit 408bf12342
5 changed files with 24 additions and 7 deletions

View File

@@ -110,9 +110,9 @@ def jobs(robot: Robot):
await robot.generate_and_send_ranking()
# ✅ 每天 15:30 发涩图 PDF
# @async_job.at_times(["15:30"])
# async def sehuatang_pdf_job():
# await robot.generate_sehuatang_pdf()
@async_job.at_times(["15:30"])
async def sehuatang_pdf_job():
await robot.generate_sehuatang_pdf()
# ✅ 每天 01:30 下载秀人网帖子
@async_job.at_times(["01:30"])

View File

@@ -47,4 +47,5 @@ pathlib~=1.0.1
Glances~=4.3.1
aiofiles~=24.1.0
aiofiles~=24.1.0
undetected-chromedriver~=3.5.5

View File

@@ -25,6 +25,7 @@ from utils.email_util import EmailSender
from utils.revoke.message_auto_revoke import MessageAutoRevoke
from utils.robot_cmd.robot_command import GroupBotManager, Feature, PermissionStatus
from utils.sehuatang.shehuatang import pdf_file_path
from utils.sehuatang.shehuatang_undetected import pdf_file_path_undetected
from utils.wechat.contact_manager import ContactManager
from utils.wechat.message_to_db import MessageStorage
from wechat_ipad import WechatAPIClient
@@ -701,7 +702,12 @@ class Robot:
async def generate_sehuatang_pdf(self):
try:
self.LOG.info("开始生成PDF,generate_sehuatang_pdf")
path = pdf_file_path()
try:
path = pdf_file_path()
except Exception as e:
self.LOG.error(f"generate_sehuatang_pdf error: {e}")
path = pdf_file_path_undetected()
# 暂时只发4K群
await self.send_group_file_message(path, Feature.PDF_CAPABILITY)
except Exception as e:

View File

@@ -6,6 +6,11 @@ import mysql.connector
from mysql.connector import Error
from selenium.webdriver.common.by import By
import undetected_chromedriver as uc
if os.name == 'nt':
try:
uc.Chrome.__del__ = lambda self: None
except Exception:
pass
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from bs4 import BeautifulSoup

View File

@@ -3,6 +3,11 @@ import os
import requests
from io import BytesIO
import undetected_chromedriver as uc
if os.name == 'nt':
try:
uc.Chrome.__del__ = lambda self: None
except Exception:
pass
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
@@ -166,10 +171,10 @@ def fetch_and_create_pdf(url):
pass
def pdf_file_path():
def pdf_file_path_undetected():
url = 'https://www.sehuatang.net/forum.php?mod=forumdisplay&fid=103&filter=typeid&typeid=481'
return fetch_and_create_pdf(url)
if __name__ == "__main__":
pdf_file_path()
pdf_file_path_undetected()