I want to screen scrape using PHP cURL from a shared server (only ports 80 and 443 are open) from behind the TOR network. I try the code below and get "Access Denied" error from my server because port 8118 and 9050 are closed. I contacted support and they said it is impossible. I doubt it, but searched forever and couldn't find an easy solution. Any thoughts?
<?php
$fh = fopen('curldebug.txt','w') or die($php_errormsg);
// Initialize cURL
$ch = curl_init();
// Set the website you would like to scrape
curl_setopt($ch, CURLOPT_URL, "http://www.fixitts.com/whatismyip.php");
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0');
curl_setopt($ch, CURLOPT_REFERER, 'http://www.fixitts.com');
curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8118');
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, $fh);
// Set cURL to return the results into a PHP variable
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// This executes the cURL request and places the results into a variable.
$curlResults= curl_exec($ch);
if(curl_errno($ch))
{
echo 'Curl error: ' . curl_error($ch);
}
$info = curl_getinfo($ch);
print_r ($info);
// Close curl
curl_close($ch);
fclose($fh) or die($php_errormsg);
// Echo the results to the screen>
echo $curlResults;
?>