sehuatang pdf 优化
This commit is contained in:
6
main.py
6
main.py
@@ -110,9 +110,9 @@ def jobs(robot: Robot):
|
|||||||
await robot.generate_and_send_ranking()
|
await robot.generate_and_send_ranking()
|
||||||
|
|
||||||
# ✅ 每天 15:30 发涩图 PDF
|
# ✅ 每天 15:30 发涩图 PDF
|
||||||
# @async_job.at_times(["15:30"])
|
@async_job.at_times(["15:30"])
|
||||||
# async def sehuatang_pdf_job():
|
async def sehuatang_pdf_job():
|
||||||
# await robot.generate_sehuatang_pdf()
|
await robot.generate_sehuatang_pdf()
|
||||||
|
|
||||||
# ✅ 每天 01:30 下载秀人网帖子
|
# ✅ 每天 01:30 下载秀人网帖子
|
||||||
@async_job.at_times(["01:30"])
|
@async_job.at_times(["01:30"])
|
||||||
|
|||||||
@@ -48,3 +48,4 @@ pathlib~=1.0.1
|
|||||||
Glances~=4.3.1
|
Glances~=4.3.1
|
||||||
|
|
||||||
aiofiles~=24.1.0
|
aiofiles~=24.1.0
|
||||||
|
undetected-chromedriver~=3.5.5
|
||||||
6
robot.py
6
robot.py
@@ -25,6 +25,7 @@ from utils.email_util import EmailSender
|
|||||||
from utils.revoke.message_auto_revoke import MessageAutoRevoke
|
from utils.revoke.message_auto_revoke import MessageAutoRevoke
|
||||||
from utils.robot_cmd.robot_command import GroupBotManager, Feature, PermissionStatus
|
from utils.robot_cmd.robot_command import GroupBotManager, Feature, PermissionStatus
|
||||||
from utils.sehuatang.shehuatang import pdf_file_path
|
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.contact_manager import ContactManager
|
||||||
from utils.wechat.message_to_db import MessageStorage
|
from utils.wechat.message_to_db import MessageStorage
|
||||||
from wechat_ipad import WechatAPIClient
|
from wechat_ipad import WechatAPIClient
|
||||||
@@ -701,7 +702,12 @@ class Robot:
|
|||||||
async def generate_sehuatang_pdf(self):
|
async def generate_sehuatang_pdf(self):
|
||||||
try:
|
try:
|
||||||
self.LOG.info("开始生成PDF,generate_sehuatang_pdf")
|
self.LOG.info("开始生成PDF,generate_sehuatang_pdf")
|
||||||
|
try:
|
||||||
path = pdf_file_path()
|
path = pdf_file_path()
|
||||||
|
except Exception as e:
|
||||||
|
self.LOG.error(f"generate_sehuatang_pdf error: {e}")
|
||||||
|
path = pdf_file_path_undetected()
|
||||||
|
|
||||||
# 暂时只发4K群
|
# 暂时只发4K群
|
||||||
await self.send_group_file_message(path, Feature.PDF_CAPABILITY)
|
await self.send_group_file_message(path, Feature.PDF_CAPABILITY)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -6,6 +6,11 @@ import mysql.connector
|
|||||||
from mysql.connector import Error
|
from mysql.connector import Error
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
import undetected_chromedriver as uc
|
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.ui import WebDriverWait
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ import os
|
|||||||
import requests
|
import requests
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import undetected_chromedriver as uc
|
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.common.by import By
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
@@ -166,10 +171,10 @@ def fetch_and_create_pdf(url):
|
|||||||
pass
|
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'
|
url = 'https://www.sehuatang.net/forum.php?mod=forumdisplay&fid=103&filter=typeid&typeid=481'
|
||||||
return fetch_and_create_pdf(url)
|
return fetch_and_create_pdf(url)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
pdf_file_path()
|
pdf_file_path_undetected()
|
||||||
Reference in New Issue
Block a user