V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
gongcheng121
V2EX  ›  问与答

Node phantomjs 如何获取页面中 iframe 中的 html

  •  
  •   gongcheng121 · 2018 年 2 月 25 日 · 3042 次点击
    这是一个创建于 2883 天前的主题,其中的信息可能已经有所发展或是发生改变。

    使用 Nodejs 进行抓取页面的时候,js 等都可以运行,但是页面中包含一个 iframe,输出抓取的 html 的时候,iframe 中是空的,没有 dom。用的包是 Node-phantomjs。

    4 条回复    2018-02-26 10:01:26 +08:00
    xycool
        1
    xycool  
       2018 年 2 月 25 日
    phantomjs --web-security=no 试试
    lemuria
        2
    lemuria  
       2018 年 2 月 25 日
    document.querySelector('selector').contentWindow.document.documentElement.outerHTML
    lemuria
        3
    lemuria  
       2018 年 2 月 25 日
    gongcheng121
        4
    gongcheng121  
    OP
       2018 年 2 月 26 日
    @lemuria ok,我试试,谢谢
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   879 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:52 · PVG 04:52 · LAX 12:52 · JFK 15:52
    ♥ Do have faith in what you're doing.