<html>
<head>
<title>GoogleGrabber</title>
<meta http-equiv=refresh content=20>
</head>

<body bgcolor=#ffffff>

<font face=Verdana size=4><B>Top Stories from Google News - refreshes every 20 seconds</B>

<p><hr><p>

<?php

require('browseremul.php'); // Contains the new class definition we need

// PHP script to grab Google News's Top Stories, from their text-only page.

// Change this to url you want to grab
$url = "http://news.google.com/news?ned=tus#s_1";

// The default UserAgent string is MSIE which is fine
$be = new BrowserEmulator(); 

// Open it with the class's fopen function
$file = $be->fopen($url);

// I think this is for debugging; don't need it for this script
$response = $be->getLastResponseHeaders();

// Read a lot (all) of it
$RetrieveFile = fread($file, 100000);

// Close the file
fclose($file);

// Stuff from the original grabber script
$GrabStart = '&nbsp;World&nbsp;';
$GrabEnd = '&nbsp;U.S.&nbsp;';

# Given $GrabStart and $GrabEnd, and passed a string ($RetrieveFile),
# it puts everything between Start and End into an array ($DataPrint).
eregi("$GrabStart.*$GrabEnd", $RetrieveFile, $DataPrint);

# Do some reformatting -- rewrite the array contents every time

# Take care of the relative links
$DataPrint[0] = str_replace('href=', 'href=http://news.google.com/news?ned=tus', $DataPrint[0]);

# Results
echo($DataPrint[0]);

?>

</body>
</html>
