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

推荐订阅源

Engineering at Meta
Engineering at Meta
G
GRAHAM CLULEY
Attack and Defense Labs
Attack and Defense Labs
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
T
Threat Research - Cisco Blogs
阮一峰的网络日志
阮一峰的网络日志
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Vercel News
Vercel News
Google DeepMind News
Google DeepMind News
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
C
CXSECURITY Database RSS Feed - CXSecurity.com
量子位
T
The Blog of Author Tim Ferriss
Project Zero
Project Zero
Webroot Blog
Webroot Blog
雷峰网
雷峰网
C
Cyber Attacks, Cyber Crime and Cyber Security
Microsoft Azure Blog
Microsoft Azure Blog
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
T
The Exploit Database - CXSecurity.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
A
About on SuperTechFans
NISL@THU
NISL@THU
AWS News Blog
AWS News Blog
Security Latest
Security Latest
S
Schneier on Security
W
WeLiveSecurity
K
Kaspersky official blog
有赞技术团队
有赞技术团队
Cyberwarzone
Cyberwarzone
P
Palo Alto Networks Blog
TaoSecurity Blog
TaoSecurity Blog
G
Google Developers Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Schneier on Security
Schneier on Security
博客园_首页
博客园 - 司徒正美
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Check Point Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Know Your Adversary
Know Your Adversary
P
Privacy & Cybersecurity Law Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"

博客园 - 至尊王者

使用 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)