简体   繁体   English

在保存的DOM上使用jQuery作为命令行

[英]Using jQuery as a command line on a saved DOM

This is something along the lines of what I'd like to do, 这是我想做的事情,

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

via a simple command line. 通过简单的命令行。 So in a nutshell, save a webpage and then query that page using jQuery. 简而言之,保存一个网页,然后使用jQuery查询该页面。

Are there any tools like this available? 有没有这样的工具?

try phantomjs , a headless webkit solution 试试phantomjs,一个无头的webkit解决方案

http://phantomjs.org/ http://phantomjs.org/

If you're willing to do this in a browser, try using YQL or your own proxy to get around cross domain ajax issues, fetch the remote page via ajax and then traverse the response. 如果您愿意在浏览器中执行此操作,请尝试使用YQL或您自己的代理来解决跨域ajax问题,通过ajax获取远程页面然后遍历响应。

F.ex using something like https://github.com/padolsey/jQuery-Plugins/tree/master/cross-domain-ajax/ F.ex使用像https://github.com/padolsey/jQuery-Plugins/tree/master/cross-domain-ajax/这样的东西

You can do 你可以做

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

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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