gongcheng121
V2EX  ›  问与答

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

  •  
  •   gongcheng121 · Feb 25, 2018 · 3234 views
    This topic created in 3006 days ago, the information mentioned may be changed or developed.

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

    4 replies    2018-02-26 10:01:26 +08:00
    xycool
        1
    xycool  
       Feb 25, 2018
    phantomjs --web-security=no 试试
    lemuria
        2
    lemuria  
       Feb 25, 2018
    document.querySelector('selector').contentWindow.document.documentElement.outerHTML
    gongcheng121
        4
    gongcheng121  
    OP
       Feb 26, 2018
    @lemuria ok,我试试,谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3158 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 223ms · UTC 11:36 · PVG 19:36 · LAX 04:36 · JFK 07:36
    ♥ Do have faith in what you're doing.