2013-05-08 82 views

回答

2

代理可以遵循。更好的方法是使用VPN。

但是如果你想代理有一些网站,例如http://www.hidemyass.com

您可以随时下载从PHP服务器一个网站,该网站在英国和保存或表现出来。我还发现本网站上的例子与代理http://www.fromzerotoseo.com/scraping-websites-php-curl-proxy/

<?php 
function getPage($proxy, $url, $referer, $agent, $header, $timeout) { 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_HEADER, $header); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_PROXY, $proxy); 
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
curl_setopt($ch, CURLOPT_REFERER, $referer); 
curl_setopt($ch, CURLOPT_USERAGENT, $agent); 

$result['EXE'] = curl_exec($ch); 
$result['INF'] = curl_getinfo($ch); 
$result['ERR'] = curl_error($ch); 

curl_close($ch); 

return $result; 
} 
?> 

用法:

$result = getPage(
'[proxy IP]:[port]', // use valid proxy 
'http://www.google.com/search?q=twitter', 
'http://www.google.com/', 
'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8', 
1, 
5);