I've never posted here before, so please bare with me...
I'm trying to strip the first page of search results from Google using regular expressions. I am able to get the URL and Title for each result, but the description is killing me. Can anyone offer ANY sort of assistance at all? I am willing to read. 🙂
I've already searched this site and read a good many forum posts, as well as a tutorial on this site (http://www.phpbuilder.com/columns/dario19990616.php3), among many others.
Here's what I've got in my test file so far:
$file is just a random result from Google so I have the format of the search results.
$file = "<p><a href=http://www.kbb.com/>Kelley Blue Book - <b>Used</b> Car Bluebook Values and New Car <b>...</b> </a>
<br><font size=-1> <b>...</b> Tools Tips Advice Automotive articles with advice about buying new and <b>used</b> <b>cars</b>.<br> Important information about recalls, crash tests and safety ratings. Get a <b>...</b>
<br><span class=f><font size=-1>Description:</font></span> New and <b>used</b> car pricing, features, information and buyers resources including links to 3 new car... <br><span class=f>Category: </span><a class=fl href=http://directory.google.com/Top/Shopping/Vehicles/Autos/Buyer_Services/>Shopping > Vehicles > Autos > Buyer Services</a><br><font color=#008000>www.kbb.com/ - 21k - 01 Mar 2002 - <a class=fl href=/search?q=cache:9DVksTSnp-UC:www.kbb.com/+used+cars&hl=en>Cached</a> - <a class=fl href=/search?hl=en&num=10&q=related:www.kbb.com/>Similar pages</a></font></font>";
$search_str = "/<p><a href=(.?)>(.?)<\/a>.?<\/span>(.?)<br>/i";
preg_match_all($search_str, $file, $matches);
print "<br><pre>";
print_r($matches);
print "</pre>";
This is what isn't working in $search_str and I don't know why...
.?<\/span>(.?)<br>
Thanks in advance for ANY help!