gongcheng121
V2EX  ›  问与答

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

  •  
  •   gongcheng121 · Feb 25, 2018 · 3272 views
    This topic created in 3034 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   ·   2925 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 14:45 · PVG 22:45 · LAX 07:45 · JFK 10:45
    ♥ Do have faith in what you're doing.