{ "status": "0", "msg": "ok", "result": { "trainno": "G34", "type": "高铁", "list": [{ "sequenceno": "1", "station": "杭州东", "day": "1", "arrivaltime": "-", "departuretime": "07:18", "stoptime": "0", "costtime": "0", "distance": "0", "isend": "0", "pricesw": "", "pricetd": "", "pricegr1": "", "pricegr2": "", "pricerw1": "0.0", "pricerw2": "0.0", "priceyw1": "0.0", "priceyw2": "0.0", "priceyw3": "0.0", "priceyd": "0.0", "priceed": "0.0" }, { "sequenceno": "2", "station": "湖州", "day": "1", "arrivaltime": "07:39", "departuretime": "07:41", "stoptime": "2", "costtime": "21", "distance": "71", "isend": "0", "pricesw": "", "pricetd": "", "pricegr1": "", "pricegr2": "", "pricerw1": "0.0", "pricerw2": "0.0", "priceyw1": "0.0", "priceyw2": "0.0", "priceyw3": "0.0", "priceyd": "55.0", "priceed": "32.5" } ] } }
<?php /** * Created by PhpStorm. * User: FZS * Time: 2020/06/06 17:26 */ class freeApi { private $apiUrl; public function __construct() { $this->apiUrl = 'http://zhouxunwang.cn/data/?id=130&key=R5RTF4G5F5H6&trainno=G34'; } /** * 获取结果 * @return array */ public function getResult() { return file_get_contents($this->apiUrl); } }
package main import ( "fmt" "io/ioutil" "log" "net/http" ) const ( APIURL = "http://zhouxunwang.cn/data/?id=130&key=R5RTF4G5F5H6&trainno=G34" ) func main() { queryUrl := fmt.Sprintf("%s",APIURL) resp, err := http.Get(queryUrl) if err != nil { log.Println(err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) }