码迷,mamicode.com
首页 > 其他好文 > 详细

temp

时间:2015-05-26 21:39:09      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

var fs = require(‘fs‘);
var async = require(‘../lib/async.js‘)
var db=require(‘../lib/mysql.js‘);
!function main(){
    async.waterfall([function(call){
       fs.readFile(‘./aaa.html‘,‘utf-8‘,call);
    },function(xml,call){
        var reg=/<div class="ycq_js_right_2_nr_left">([^<]+)<\/div>/g,
            reg2=/<div class="ycq_js_right_2_nr_right_2">([^<]+)<\/div>/,
            imgreg=/\/static\/image\/\d+W.jpg/;
        var desc1=reg.exec(xml)[1],
            desc3=reg.exec(xml)[1],
            desc4=reg.exec(xml)[1],
            desc2=reg2.exec(xml)[1],
            image=imgreg.exec(xml)[0]
        call(null,{
            desc1:desc1,
            desc2:desc2,
            desc3:desc3,
            desc4:desc4,
            image:image
        });
    },function(weekDesc,call){
        weekDesc.id=3;
        weekDesc.$table=‘weeks_tab‘;
//        db.exec(‘insert into weeks_tab values(#{id},#{desc1},#{desc2},#{desc3},#{desc4},#{image})‘,weekDesc,call);
        db.save(weekDesc,call);
    }],function(err,res){
        err&&console.log(err);
        console.log(res);
    });
}()



temp

标签:

原文地址:http://my.oschina.net/u/590489/blog/420268

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!