Topic awaiting preservation: Scraper not working |
|
---|---|
Author | Thread |
Obsessive-Compulsive (I) Inmate From: |
posted 11-09-2011 22:07
I'm not getting any errors. It just isn't working. code: <? $html = file_get_contents("http://www.yellowpages.com/fort-lauderdale-fl/acupunture"); preg_match_all( '/ <div class="listing_content">.*? <h3 .*?> <a .*?>(.*?)<\/a> <\/h3> <span class="listing-address adr"> <span class="street-address">(.*?)<\/span> <span class="city-state"> <span class="locality">(.*?)<\/span>, <span class="region">(.*?)<\/span> <span class="postal-code">(.*?)<\/span> <\/span> <\/span> <span class="business-phone phone">(.*?)<\/span>.*? <li><a href="(.*?)">/s', $html, $posts, PREG_SET_ORDER ); $listing=array(); foreach ($posts as $post) { $listing['title'][] = $post [ 1 ]; $listing['street'][] = $post [ 2 ]; $listing['city'][] = $post [ 3 ]; $listing['state'][] = $post [ 4 ]; $listing['zip'][] = $post [ 5 ]; $listing['phone'][] = $post [ 6 ]; $listing['website'][] = $post [ 7 ]; // do something with data echo $post [ 4 ]; } print_r($listing) ?>
|
Maniac (V) Mad Scientist with Finglongers From: Germany |
posted 11-10-2011 16:59
If you see no errors, you should see an empty array being output - that means your regular expression is not matching. |
Nervous Wreck (II) Inmate From: |
posted 11-14-2011 16:21
TY, its working now |