加入分页,逆序排列帖子

This commit is contained in:
liuwei
2025-03-03 15:41:18 +08:00
parent 47e7ade2f7
commit 34607efd32

View File

@@ -8,7 +8,7 @@ from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from bs4 import BeautifulSoup
from reportlab.lib.pagesizes import letter
from reportlab.lib.pagesizes import letter, A3
from reportlab.lib import colors
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image, PageBreak
from reportlab.lib.styles import getSampleStyleSheet
@@ -98,7 +98,7 @@ def fetch_and_create_pdf(url):
# 设置PDF
pdf_filename = f"JAV-{today}-{len(today_posts)}.pdf"
doc = SimpleDocTemplate(pdf_filename, pagesize=letter)
doc = SimpleDocTemplate(pdf_filename, pagesize=A3)
# 遍历帖子
for post in today_posts:
@@ -145,7 +145,7 @@ def fetch_and_create_pdf(url):
if image:
img = PILImage.open(image)
img_width, img_height = img.size
image_width = 450
image_width = 500
image_height = int((img_height / img_width) * image_width)
img_stream = BytesIO(image.getvalue())
content.append(Image(img_stream, width=image_width, height=image_height))