temp

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)