2016年8月30日
2016-08-31 本文已影响0人
zy01
火车票查询接口
node.js
var icon = require('iconv-lite');
var request =require('request');
var md5 = require('md5');
var mongoose = require('mongoose');
var moment = require('moment');
exports.railway=function(req,res){
var obj = req.body;
var url = '/otn/leftTicker/query?leftTicketDTO
.tra in_date=20160831$leftTicketDTO.from_station
=上海$leftTicketDTO.to_station=北京$purpose_codes
=ADULT';
var options={
hosenme:'kyfw.12306.cn',
port:443,
method: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',function(e){
console.log("错误");
});
request.eng();
})
}