我目前有一个脚本,可以在这里找到:http: //ddelay.co.uk/bus/find_services2.php
使用以下代码:
<?php
include('simple_html_dom.php');
$service = $_GET["stop"];
$debug = $_GET["debug"];
$url = $service;
if($debug === "yes"){
echo "URL IS: " . $url . "\n";
}
$search = array('?', ' ', '.asp&');
$replace = array('&', '+', '.asp?');
$url2 = str_replace($search, $replace, $url);
if($debug === "yes"){
echo "REPLACEMENTS: ". $url2 . "\n";
}
$end = "http://tsy.acislive.com" . $url2 . '&showall=1';
if($debug === "yes"){
echo "FINAL URL: ". $end;
}
$html = file_get_html($end);
$ret = $html-> getElementsByTagName('table');
print($ret);
?>
例如将从 tsy.acislive.com 拉表(例如:http ://ddelay.co.uk/bus/find_services2.php?stop=/web/public_service_stops.asp?service=22?operatorid=36?systemid =30?goingto=伍德豪斯)
然后我希望能够将此表转换为 JSON 数据以在我的应用程序中使用。不幸的是,我尝试过 PHP 的函数 JSON_encode($ret); 但不幸的是,失败了。有人知道我如何将使用 Simple-Dom-Parser php 提取的这个表转换为 Json Data