Skip to content

Instantly share code, notes, and snippets.

@zachbrowne
Created October 31, 2011 06:54
Show Gist options
  • Save zachbrowne/1327048 to your computer and use it in GitHub Desktop.
Save zachbrowne/1327048 to your computer and use it in GitHub Desktop.
Use proxy to scrape with PHP
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '<a class="linkclass" href="http://www.example.com">http://www.example.com</a>');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, 'fakeproxy.com:1080');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:password');
$data = curl_exec();
curl_close($ch);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment