0

这是我想做的事情,

web_page = fetch("http://www.google.com")
console.log($(web_page).find("body"))

通过一个简单的命令行。所以简而言之,保存一个网页,然后使用 jQuery 查询该页面。

有没有这样的工具可用?

4

3 回答 3

2

尝试 phantomjs ,一个无头 webkit 解决方案

http://phantomjs.org/

于 2012-12-13T22:50:39.927 回答
0

如果您愿意在浏览器中执行此操作,请尝试使用 YQL 或您自己的代理来解决跨域 ajax 问题,通过 ajax 获取远程页面,然后遍历响应。

F.ex 使用类似https://github.com/padolsey/jQuery-Plugins/tree/master/cross-domain-ajax/

你可以做

$.get('http://google.com', function(html) {
    console.log( $(html).find('body') );
});​​​​​​​​​​​​​​

演示:http: //jsfiddle.net/uc7vt/

于 2012-12-13T22:52:54.213 回答
0

如果你熟悉 Node.js, npm install jquery

于 2012-12-13T23:05:48.940 回答