q為車次ver為當前毫秒時間戳cityname按車次查詢時為123456
二、結果數據
string(3634) “XQScript_5(
{“ticketInfo”:
{“2192\/2193″:[
{"pr":88.5,"type":"硬座"},
{"pr":183.5,"type":"硬臥中"},
{"pr":304.5,"type":"軟臥下"}]},”trainInfo”:
{“2192\/2193″:
{“arriCity_py”:”zhengzhou”,”istmp”:false,”code”:”2192\/2193″,”deptCity_py”:”wenzhou”,”arriStation”:”鄭州”,”arriCity”:”鄭州”,”trainType”:”普快”,”deptTime”:”13:52″,”deptStation”:”溫州”,”deptCity”:”溫州”,”arriTime”:”14:20″,”interval”:”1天28分”}},”trainScheduleHead”:["站次","站名","日期","到達時間","開車時間","停車時間","里程","硬座","軟座","二等軟座","一等軟座","硬臥上\/中\/下","軟臥上\/下"],”extInfo”:
{“allMileage”:”1496公里”,”allTime”:”1天28分”},”trainScheduleBody”:[
{"mxl":34521376777470,"content":[83,"長興南","第一天","23:25","23:29","4分","575公里",110,"0","0","0","154\/157\/160","204\/210"]},
{“content”:[34,"武義","第一天","17:31","17:33","2分","222公里",46.5,"0","0","0","80.5\/83.5\/85.5","107.5\/111.5"]},
{“content”:[17,"麗水","第一天","16:00","16:03","3分","136公里",24.5,"0","0","0","58.5\/61.5\/63.5","81.5\/85.5"]},
{“content”:[62,"蕪湖","第二天","01:53","02:00","7分","753公里",99,"0","0","0","153\/157\/161","217\/224"]},
{“content”:[24,"宣城","第二天","00:55","01:03","8分","689公里",57,"0","0","0","107\/110\/114","165\/173"]},
{“content”:[45,"德清西","第一天","22:27","22:37","10分","517公里",70,"0","0","0","111\/113\/116","156\/161"]},
{“content”:[55,"縉雲","第一天","16:35","16:37","2分","168公里",63.5,"0","0","0","97.5\/100.5\/102.5","122.5\/126.5"]},
{“content”:[93,"永康","第一天","17:08","17:11","3分","201公里",104.5,"0","0","0","138.5\/141.5\/143.5","164.5\/168.5"]},
{“content”:[76,"青田","第一天","14:44","14:48","4分","57公里",78,"0","0","0","112\/115\/117","131.5\/135.5"]},
{“content”:[38,"溫州","-","起點站","13:52","-",0,37,0,0,0,"37\/37\/37","37\/37"]},
{“content”:[51,"杭州","第一天","21:30","21:44","14分","449公里",73.5,"0","0","0","110.5\/113.5\/115.5","150.5\/155.5"]},
{“mxl”:16076029707508,”content”:[58,"亳州","第二天","10:15","10:22","7分","1219公里",114.5,"0","0","0","190.5\/196.5\/202.5","288.5\/300.5"]},
{“mxl”:7253046021614,”content”:[79,"淮南","第二天","05:49","05:55","6分","989公里",125.5,"0","0","0","191.5\/196.5\/201.5","274.5\/284.5"]},
{“mxl”:19294423176992,”content”:[69,"開封","第二天","13:10","13:24","14分","1424公里",131.5,"0","0","0","216.5\/223.5\/230.5","328.5\/341.5"]},
{“content”:[100,"巢湖","第二天","02:53","02:59","6分","830公里",140,"0","0","0","198\/202\/207","269\/278"]},
{“content”:[41,"合肥","第二天","03:54","04:14","20分","894公里",82,"0","0","0","142\/146\/151","216\/225"]},
{“content”:[13,"義烏","第一天","19:41","19:46","5分","310公里",28.5,"0","0","0","62.5\/65.5\/67.5","93.5\/97.5"]},
{“content”:[20,"阜陽","第二天","07:50","08:20","30分","1115公里",71.5,"0","0","0","143.5\/148.5\/154.5","234.5\/245.5"]},
{“content”:[96,"商丘","第二天","11:17","11:21","4分","1293公里",153.5,"0","0","0","232.5\/238.5\/244.5","333.5\/345.5"]},
{“content”:[72,"金華西","第一天","18:52","19:07","15分","262公里",85.5,"0","0","0","119.5\/122.5\/124.5","148.5\/152.5"]},
{“content”:[31,"蘭考","第二天","12:29","12:39","10分","1381公里",91.5,"0","0","0","174.5\/181.5\/187.5","282.5\/295.5"]},
{“mxl”:16683831947510,”content”:[107,"鄭州","第二天","14:20","終到站","-","1496公里",170.5,"0","0","0","258.5\/265.5\/272.5","372.5\/386.5"]},
{“mxl”:9451012451240,”content”:[90,"民權","第二天","12:04","12:07","3分","1345公里",149.5,"0","0","0","230.5\/236.5\/243.5","335.5\/347.5"]}]});”
複製代碼
三、源代碼
var_dump(getTrainInfo(“t110″));
function getTrainInfo($line)
{
$curTime = explode (” “, microtime());
$curMicroTime = round($curTime[1].($curTime[0]*1000));
$url = “http://train.qunar.com/qunar/checiInfo.jsp?ex_track=&q=”.$line.”&format=json&cityname=123456&ver=”.$curMicroTime.”&callback=XQScript_5″;
$headers = array(
”User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1″,
”Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8″,
”Accept-Language: en-us,en;q=0.5″,
//”Accept-Encoding: gzip, deflate”,
”Referer:
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
?>
複製代碼
四、遺留問題
返回數據不是按順序排列的。。。。。。需要再找排列的算法