Skip to content

Instantly share code, notes, and snippets.

@gati
Created July 11, 2011 18:31
Show Gist options
  • Save gati/1076465 to your computer and use it in GitHub Desktop.
Save gati/1076465 to your computer and use it in GitHub Desktop.
Quick scrape using simple_html_dom
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