Forum Moderators: coopster
<?PHP
//url
$url = 'http://abc.com/somefile.html';
//get the page content
$imdb_content = get_data($url);
//parse for product name
$name = get_match('/<div class="matchHeaderTeamText">(.*)<\/div>/isU',$imdb_content);
$team = get_match('/<div class="matchHeaderScore">(.*)<\/div>/isU',$imdb_content);
echo $team[0] . "<br /><br /><br />";
$team = get_match('/<p class="teamText">(.*)<\/p>/isU',$imdb_content);
$rr = get_match('/<div class="matchHeaderLeft">(.*)<\/div>/isU',$imdb_content,$imdb_content );
//build content
$content.= '<h2>Line: '.$name.'</h2>';
$content.= 'Run Rate ' .$rr. '';
$content.= '<br />Team ' .$team. '';
echo $content;
//gets the match content
function get_match($regex,$content)
{
preg_match($regex,$content,$matches);
return $matches[1];
}
//gets the data from a URL
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
//gets the match content
function get_match($regex,$content)
{
preg_match_all($regex,$content,$matches);
return $matches[1];
}
function get_match($regex,$content)
{
preg_match_all($regex,$content,$matches);
return $matches[1];
}
$imdb_content = <<<ENDOFHTML
<table>
<tr><td>Table Row 1</td></tr>
<tr><td>Table Row 2</td></tr>
<tr><td>Table Row 3</td></tr>
</table>
<p>Nothing here</p>
<table>
<tr><td>Table Row 4</td></tr>
<tr><td>Table Row 5</td></tr>
<tr><td>Table Row 6</td></tr>
</table>
<p>Nothing here</p>
ENDOFHTML;
$team = get_match('/<tr>(.*)<\/tr>/isU',$imdb_content);
print '<pre>';
print_r($team);
print '</pre>';
exit;