冲浪网站从不同的国家IP


Surf a site from different country IP

我想使用英国的代理ip浏览网站。

这在php中可能吗?如果是,请告诉我

可以遵循Proxy。更好的方法是使用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);