- Impact
- 38
Regular Expression Help
Hi All,
I am loading a craigslist page through CURL and I have the page contents loaded as a PHP variable. I need to locate a couple of things on this page:
http://sandiego.craigslist.org/off/438472718.html
I need the loc variable from this link (google map link on above page):
http://maps.google.com/?q=loc:+Balboa+Avenue+at+Genesee+San+Diego+CA+US
I also would like to have the src value of the photos (up to 4 photos) from that listing page.
I think what I need is a regular expression to find these matches, but there may be something easier (for instance if I could use the DOM then it would be much easier to look for these matches). Any help or hard code is appreciated.
For the code minded:
Hi All,
I am loading a craigslist page through CURL and I have the page contents loaded as a PHP variable. I need to locate a couple of things on this page:
http://sandiego.craigslist.org/off/438472718.html
I need the loc variable from this link (google map link on above page):
http://maps.google.com/?q=loc:+Balboa+Avenue+at+Genesee+San+Diego+CA+US
I also would like to have the src value of the photos (up to 4 photos) from that listing page.
I think what I need is a regular expression to find these matches, but there may be something easier (for instance if I could use the DOM then it would be much easier to look for these matches). Any help or hard code is appreciated.
For the code minded:
PHP:
require_once 'rss_fetch.inc';
$url = 'http://sandiego.craigslist.org/off/index.rss';
$rss = fetch_rss($url);
echo "Site: ", $rss->channel['title'], "<br>";
foreach ($rss->items as $item ) {
$title = $item['title'];
$url = $item['link'];
echo "<a href=$url>$title</a><br />\n";
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,$url);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (empty($buffer))
{
print "Sorry, example.com are a bunch of poopy-heads.<p>";
}
else
{
print $buffer;
//this is where I'm at
$googleLink = ???????
$images[] = ??????
}
}







