【问题标题】:node.js parse a page and catch external frontend js errorsnode.js 解析页面并捕获外部前端 js 错误
【发布时间】:2015-05-31 22:32:31
【问题描述】:

是否可以解析有一些 js 错误(例如“$ 未定义”)的外部页面 http://example.com,捕获这些错误并通过 console.log() 打印它们?

【问题讨论】:

    标签: javascript node.js parsing cheerio


    【解决方案1】:

    是的,这是可能的。基本上你需要下载一个页面并在无头浏览器中呈现它,例如PhantomJS

    已经有人这样做了:http://npmjs.com/package/phantom-check

    $ phantom-check http://example.com
    Phantom is checking http://example.com
    
    [info] [phantom] Starting...
    [info] [phantom] Running suite: 2 steps
    [debug] [phantom] opening url: http://example.com/, HTTP GET
    [debug] [phantom] Navigation requested: url=http://example.com/, type=Other, willNavigate=true, isMainFrame=true
    [debug] [phantom] url changed to "http://example.com/"
    [debug] [phantom] Successfully injected Casper client-side utilities
    
    Page http://example.com has no errors
    

    【讨论】:

      猜你喜欢
      • 2016-10-26
      • 2011-06-18
      • 1970-01-01
      • 2011-09-12
      • 1970-01-01
      • 2018-12-24
      • 2020-12-18
      • 1970-01-01
      • 2018-05-17
      相关资源
      最近更新 更多