You can fetch data from a webpage by using this script. It is useful when you need to fetch data like Stock Rates on your site.
Like if you want to fetch data between span tags.
<?php
// retrieve htmltagcontent tag contents
function get_htmltagcontent($file){
$h1tags = preg_match_all(‘/(<span>)(.*)(</span>)/ismU’,$file,$patterns);
$res = array();
array_push($res,$patterns[2]);
array_push($res,count($patterns[2]));
return $res;
}
$url_base=”http://Specify Base URL/”;
$url_dir=”Specify Directory Here or Leave it Blank”;
$pages_start=”1″;
$pages_num=”2″;
$pages_rows=”10″;
for($i=$pages_start; $i<($pages_num+$pages_start); $i++)
{
$url_query=($i*$pages_rows).”/”; //Create URL Query Part here
$url=$url_base.$url_dir.$url_query;
$file = file_get_contents($url);
$htmltagcontent = get_htmltagcontent($file);
if($htmltagcontent[1] != 0)
{
foreach($htmltagcontent[0] as $key => $val){
echo “<li>####” . $val . “</li>”;
}
echo “</ul>”;
}
else
{
echo “<br/><div class=”error”>No Tags found</div><br/>”;
}
}
?>