惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Securelist
K
Kaspersky official blog
V
Vulnerabilities – Threatpost
C
Cisco Blogs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
Forbes - Security
Forbes - Security
Spread Privacy
Spread Privacy
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Palo Alto Networks Blog
H
Hacker News: Front Page
L
Lohrmann on Cybersecurity
Cloudbric
Cloudbric
S
Schneier on Security
Simon Willison's Weblog
Simon Willison's Weblog
I
InfoQ
人人都是产品经理
人人都是产品经理
PCI Perspectives
PCI Perspectives
月光博客
月光博客
爱范儿
爱范儿
Jina AI
Jina AI
WordPress大学
WordPress大学
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
Google Online Security Blog
Google Online Security Blog
W
WeLiveSecurity
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
博客园 - 司徒正美
Scott Helme
Scott Helme
AI
AI
L
LangChain Blog
A
Arctic Wolf
博客园 - 【当耐特】
量子位
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
MyScale Blog
MyScale Blog
腾讯CDC
博客园 - 叶小钗
Last Week in AI
Last Week in AI
S
Secure Thoughts

博客园 - 至尊王者

使用 Android Lua Helper 在VSCODE中调试安卓Lua应用 lua语言特性及用途 Ollvm混淆与反混淆: goron框架字符串加密的实现原理 Ollvm混淆与反混淆: Goron框架编译与使用 安卓使用OLLVM混淆.so reinterpret_cast和其它cast的区别 雷电9中使用Fiddler抓包 ubuntu 22.04离线安装cuda 11.7.1、cudnn 8.9.3.28、nccl 2.18.3、tensorrt 8.6.1 C/C++程序隐藏符号 配置ETH 2.0 同步节点 Nethermind & Prysm rust在windows上编译openssl mac 远程桌面 the user account did not work的解决办法 MacOS静态编译ffmpeg 4.4.1、x264、x265等编解码库的脚本 Linux、Windows静态编译ffmpeg 4.4.1、x264、x265等编解码库的脚本 Visual Studio 2022 Key 在Docker中安装宝塔面板 idea/clion行注释位置(不在首列,注释就靠近代码块) linux手动编译llvm/clang linux与windows双系统保持时间同步
Puppeteer: 等待打开一个新页面
至尊王者 · 2021-01-10 · via 博客园 - 至尊王者

对于点击 <a target='_blank'> 标签打开新 tab 页的场景,Puppeteer目前(2019-03,v1.13.0)没有现成的 API 支持。因此需要一些 walkaround 来解决。有几个方案。

提取 href,手动打开新 page 去访问

url = await page.evaluate('() => $("a").attr("href")')
detail_page = await browser.newPage()
# goto 带了 waitForNavigation 的作用
await detail_page.goto(detail_page_url)

使用点击,再去轮徇 pages

代码如下。这个方案的问题在于,拿到 detail_page 时并不知道页面是否 load 完成了,在这个时候调用 .waitForNavigation() 可能会超时报错(因为没有 load 事件被 fire)。如果页面有 AJAX 请求,你可能需要写额外的 waitForSelector 来确保你要的数据已经在页面上。

# 点击完后出现新 tab 页
await page.click(f'#panel-5 tr:nth-child({index + 1}) a')

# 等新 Tab 页 ready,即 pages 中有新 tab 页。由于没有现成 API,只能靠等
detail_page = None
for i in range(5):
    pages = await browser.pages()
    try:
        detail_page = next(page for page in pages if 'biangeng.html' in page.url)
    except StopIteration:
        await asyncio.sleep(1)
    else:
        break
if detail_page is None:
    msg = "New page did not show up or show up so slowly."
    logger.error(msg)
    raise Exception(msg)