简体   繁体   中英

node.js parse a page and catch external frontend js errors

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

Yes, it is possible. Basically you need to download a page and render it in a headless browser such as PhantomJS .

Someone has done this already: 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM