mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
commit
1e2c9ca28a
@ -318,33 +318,34 @@ async def get_user_dynamic(
|
|||||||
browser = await get_browser()
|
browser = await get_browser()
|
||||||
if dynamic_info.get("cards") and browser:
|
if dynamic_info.get("cards") and browser:
|
||||||
dynamic_upload_time = dynamic_info["cards"][0]["desc"]["timestamp"]
|
dynamic_upload_time = dynamic_info["cards"][0]["desc"]["timestamp"]
|
||||||
|
dynamic_id = dynamic_info["cards"][0]["desc"]["dynamic_id"]
|
||||||
if local_user.dynamic_upload_time < dynamic_upload_time:
|
if local_user.dynamic_upload_time < dynamic_upload_time:
|
||||||
context = await browser.new_context()
|
context = await browser.new_context()
|
||||||
page = await context.new_page()
|
page = await context.new_page()
|
||||||
try:
|
try:
|
||||||
await page.goto(
|
await page.goto(
|
||||||
f"https://space.bilibili.com/{local_user.uid}/dynamic",
|
f"https://t.bilibili.com/{dynamic_id}",
|
||||||
wait_until="networkidle",
|
wait_until="networkidle",
|
||||||
timeout=10000,
|
timeout=10000,
|
||||||
)
|
)
|
||||||
# await page.set_viewport_size({"width": 2560, "height": 1080, "timeout": 10000*20}) # timeout: 200s
|
# await page.set_viewport_size({"width": 2560, "height": 1080, "timeout": 10000*20}) # timeout: 200s
|
||||||
# 删除置顶
|
# 删除置顶
|
||||||
await page.evaluate(
|
# await page.evaluate(
|
||||||
"""
|
# """
|
||||||
xs = document.getElementsByClassName('bili-dyn-item__tag');
|
# xs = document.getElementsByClassName('bili-dyn-item__tag');
|
||||||
for (x of xs) {
|
# for (x of xs) {
|
||||||
x.parentNode.parentNode.remove();
|
# x.parentNode.parentNode.remove();
|
||||||
}
|
# }
|
||||||
"""
|
# """
|
||||||
)
|
# )
|
||||||
async with page.expect_popup() as popup_info:
|
# async with page.expect_popup() as popup_info:
|
||||||
await page.locator(".bili-rich-text__content").click()
|
# await page.locator(".bili-rich-text__content").click()
|
||||||
details_page = await popup_info.value
|
# details_page = await popup_info.value
|
||||||
await details_page.set_viewport_size(
|
await page.set_viewport_size(
|
||||||
{"width": 2560, "height": 1080, "timeout": 10000 * 20}
|
{"width": 2560, "height": 1080, "timeout": 10000 * 20}
|
||||||
)
|
)
|
||||||
await details_page.wait_for_selector(".panel-area")
|
await page.wait_for_selector(".panel-area")
|
||||||
await details_page.evaluate(
|
await page.evaluate(
|
||||||
"""
|
"""
|
||||||
xs = document.getElementById('internationalHeader');
|
xs = document.getElementById('internationalHeader');
|
||||||
xs.remove();
|
xs.remove();
|
||||||
@ -352,7 +353,7 @@ async def get_user_dynamic(
|
|||||||
xs[0].remove();
|
xs[0].remove();
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
card = details_page.locator(".detail-card")
|
card = page.locator(".detail-card")
|
||||||
await card.wait_for()
|
await card.wait_for()
|
||||||
await card.screenshot(
|
await card.screenshot(
|
||||||
path=dynamic_path / f"{local_user.sub_id}_{dynamic_upload_time}.jpg",
|
path=dynamic_path / f"{local_user.sub_id}_{dynamic_upload_time}.jpg",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user