Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
error_reporting(-1);
ini_set('display_errors', 'on');
$response = file_get_contents("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fwww.dallaspolice.net%2Fmediaaccess%2FDefault.aspx%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2F*%5B%40id%3D%22grdData_ctl01%22%5D%2Ftbody'&format=json");
$json = json_decode($response);
$reports = array();
if(isset($json->query->results))
{
$results = $json->query->results;
$i = 0;
foreach($results->tbody->tr as $tr)
{
$reports[$i]['incident_num'] = $tr->td[1]->p;
$reports[$i]['division'] = $tr->td[2]->p;
$reports[$i]['nature_of_call'] = $tr->td[3]->p;
$reports[$i]['priority'] = $tr->td[4]->p;
$reports[$i]['date_time'] = $tr->td[5]->p;
$reports[$i]['unit_num'] = $tr->td[6]->p;
$reports[$i]['block'] = $tr->td[7]->p;
$reports[$i]['location'] = $tr->td[8]->p;
$reports[$i]['beat'] = $tr->td[9]->p;
$reports[$i]['reporting_area'] = $tr->td[10]->p;
$reports[$i]['status'] = $tr->td[10]->p;
$i++;
}
}
echo json_encode($reports);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment