From 80dd0b8c4509c0fc40381c7fe6b04b20debd2328 Mon Sep 17 00:00:00 2001 From: fllesser Date: Thu, 9 Jan 2025 12:04:15 +0800 Subject: [PATCH] update shop.py --- nonebot_plugin_fortnite/shop.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nonebot_plugin_fortnite/shop.py b/nonebot_plugin_fortnite/shop.py index 4cc5f43..fc8e730 100644 --- a/nonebot_plugin_fortnite/shop.py +++ b/nonebot_plugin_fortnite/shop.py @@ -15,11 +15,12 @@ async def screenshot_shop_img() -> Path: async with async_playwright() as p: try: - browser = await p.chromium.launch(headless=True) # 启动无头模式的 Chromium 浏览器 + browser = await p.chromium.launch(headless=True, ignore_https_errors=True) # 启动无头模式的 Chromium 浏览器 # page = await browser.new_page() context = await browser.new_context( extra_http_headers = { - 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36", + 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36", + 'Referer': 'https://fortnite.gg', 'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", 'Accept-Encoding': "gzip, deflate", 'upgrade-insecure-requests': "1", @@ -46,6 +47,7 @@ async def screenshot_shop_img() -> Path: # }]) page = await context.new_page() + await page.add_style_tag(content='* { transition: none !important; animation: none !important; }') await page.goto(url, wait_until='networkidle', timeout=60000) # await page.wait_for_load_state('load') # 等待页面加载完毕 await page.screenshot(path=shop_file, full_page=True)