I've been trying for over a month now and I can't get it to work

I'm trying to make a little widget for my site that parses Google results
so that my visitors don't have to go away from the site

This is what I've done so far:

// open the site
$handle=fopen("full url for searching", 'r');

// place it in a string
while (!feof($handle))
$content .= fgets($handle, 4096);

// strip out the divs with data
preg_match('/<div class=\"g\">.*<\/div>/', $content, $result);

// output the results
foreach($result as $div)
echo $div;
After that I try and parse each div so I would get the URL, title and
description, but it doesn't work..

I've tried &output=xml - but Google banned that approach.

Can anybody give a hand?
What I would like to get as the result is:


Thanks in advance!