DarkMindZ Codebase
[ PHP ]Get news from google news
View Plain Text VersionAuthors Comments:
Code:
<?PHP
$input = browse("http://www.google.com/news?ned=us&topic=t"); // the part of google news we want to browse
echo Get_Topic($input, 1, '<div class=lh>', '<br><font'). " ";
echo Get_Topic($input, 2, '<div class=lh>', '<br><font'). " ";
echo Get_Topic($input, 3, '<div class=lh>', '<br><font'). " ";
echo Get_Topic($input, 4, '<div class=lh>', '<br><font'). " ";
echo Get_Topic($input, 5, '<div class=lh>', '<br><font'). " ";
echo Get_Topic($input, 6, '<div class=lh>', '<br><font');
function browse($url) // function to get data from Curl
{
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt ($ch, CURLOPT_TIMEOUT, '10');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
return $store;
}
function Get_Topic($source, $num, $preg, $preg1) // simpler than regular expressions
{
#$preg = '<div class=lh>';
#$preg1 = '<br><font';
$parts = explode($preg, $source);
$parts = explode($preg1, $parts[$num]);
$var = $parts[0];
return $parts[0];
}
?>Submitted by: Mad-Hatter