【问题标题】:how to get sub iframes in puppeteer?如何在 puppeteer 中获取子 iframe?
【发布时间】:2020-04-13 06:00:02
【问题描述】:

如何在 iframe 中获取 iframe

现在目标网页包含 iframe 并且在主 iframe 内还有另一个 iframe

page.frames() and page.mainFrame().childFrames() 只是返回主 iframe

iframe->iframe ??

【问题讨论】:

    标签: javascript node.js puppeteer webautomation


    【解决方案1】:

    您可以浏览 childs 数组。 mainFrame 不是指您的第一个 iFrame,而是指页面本身,它被视为一个框架。

    page.frames()[0].childFrames()
    

    【讨论】:

    • 看看this test 以及它如何使用this function 导航these frames
    • 感谢您的 cmets。 ) 但我通过使用 is const mainIframe = document.querySelector('iframe') const captchaItem = mainIframe.contentWindow.document.querySelector( 'iframe'
    • 如果您的框架是 elementHandle(您使用评估或 $ 获得的框架),您可以调用 contentFrame 函数,该函数将为您提供 Frame 对象。
    • 是的,看来这也是一个解决方案。但是哪个更好呢?
    猜你喜欢
    • 2021-08-22
    • 1970-01-01
    • 2022-12-13
    • 2023-02-05
    • 1970-01-01
    • 2019-09-17
    • 1970-01-01
    • 2023-03-22
    • 2020-11-29
    相关资源
    最近更新 更多