NodeJs火车票查询接口0830

var icon=rquire('iconv-lite');
var request=require('request');
var md5=rquire('md5');
var mongoose=require('mongoose');
var moment=require('moment');



exports.railway=function(req,res){
    var obj=req.body;
    var url='/otn/leftTicket/query?leftTicketDTO.train_date=20160831&leftTicketDTO.from_station=上海&leftTicketDTO.to_station=北京&purpose_codes=ADULT';
var options={
    hostnme:'kyfw.12306.cn',
    port:443,
    path:url,
    method:'GET',
    rejectUnauthorized:false

};

var request=https.request(options,function(response){
    response.setEncoding('utf8');

    var str='';

    response.on('data',function(chunk){
        str+=chunk;
    });

    //完成拼装
    request.on('error',funcion(e){
        console.log('错误信息:'+e.message);
    });
    request.end();
})

}



展开阅读全文

没有更多推荐了,返回首页