javascript - node.js 解析页面并捕获外部前端 js 错误

标签 javascript node.js parsing cheerio

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

最佳答案

是的,这是可能的。基本上,您需要下载页面并将其呈现在 headless 浏览器中,例如 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

关于javascript - node.js 解析页面并捕获外部前端 js 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30563396/

相关文章:

javascript - React-Redux : Infinite loop when concat to an array in state?

javascript - 需要表格来填充搜索栏的搜索结果

c# - 我如何为特定城市或国家设计伊斯兰祈祷时间小部件?

node.js - nodejs 使用的 Error 构造函数的参数是什么?

javascript - 使用 jQuery 将 json 值返回到表单字段

javascript - socket.io 让我感到困惑,我怎样才能通过我已经拥有的相同端口建立连接?

node.js - NodeJS async.Whilst

php - 来自 URI 的自定义主体类

java - 解析大型 XML 文件并获取重复属性

python - 从 Python 文件中读取行的更好方法是什么?