Created
July 11, 2011 18:31
-
-
Save gati/1076465 to your computer and use it in GitHub Desktop.
Quick scrape using simple_html_dom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include('simple_html_dom.php'); // DOM parsing library. | |
$url = (isset($_GET['site'])) ? $_GET['site'] : 'http://www.yelp.com'; //just an example, clean this | |
$dom = file_get_html($url); | |
foreach ($dom->find('a') as $node) { | |
// Replace href attribute value | |
$node->href = 'http://YOURPROXYSERVER.COM?requestedurl='.urlencode($url.$node->href); | |
} | |
// Output modified DOM | |
echo $dom->outertext; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment