是否可以解析具有一些js错误的外部页面http://example.com(例如' $未定义'),捕获这些错误并通过console.log()打印它们?
答案 0 :(得分: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