1
loading 2013-12-18 21:10:21 +08:00
网页截图
|
2
standin000 OP @loading 截图就变成图片了,我想要HTML文件
|
3
standin000 OP var $ = require('jquery');
var fs = require('fs'); var request = require('request'); var download = function(uri, filename){ request.head(uri, function(err, res, body){ request(uri).pipe(fs.createWriteStream(filename)); }); }; fs.readFile('./1.html',function(err,data){ if(err) throw err; HTML = data.toString(); var new_html = $(HTML); var oldsrc,src; new_html.find('img').each(function(index,image){ oldsrc = $(image).attr('src'); src = oldsrc.replace(/^.*\//, './'); download(oldsrc, src); $(image).attr('src', src); }); console.log(new_html[0].innerHTML); }); 没有找到,自己搞定! |