TORネットワークの背後にある共有サーバー(ポート80と443のみが開いている)からPHPcURLを使用してスクレイピングをスクリーニングしたいと思います。以下のコードを試してみると、ポート8118と9050が閉じているため、サーバーから「アクセスが拒否されました」というエラーが表示されます。サポートに連絡したところ、不可能だと言われました。私はそれを疑っていますが、永遠に検索し、簡単な解決策を見つけることができませんでした。何かご意見は?
<?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;
?>