1

[Problem]

There is a website which works for US-citizens only (shows info "A" for US-citizens, info "B" for non-US citizens). I need to constantly monitor this webpage for changes ("A" info) - an email should be sent when something is changed! How do I do it? The problem is that I live in Europe!

[Already accomplished]

I have a linux server, daemon and curl PHP script which accomplishes the following task! It works great for all "non-US-only" websites.

[Question]

One way to solve the problem might be to rent a US server but that's not acceptable at all and it is going to cost a lot! I believe that another way to solve the problem might be - to use a US VPN on my server, but for some reasons I won't do that. Is there a way to run curl through proxy maybe? Any ideas?

Current code is the following:

function getrequest($url_site/*,$post_data*/) {
    $ch = curl_init();  
    curl_setopt($ch, CURLOPT_URL,$url_site);
    curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3');
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);  
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_FILE);   // Cookie management.
    curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_FILE);
    $result = curl_exec($ch); // run the whole process 
    curl_close($ch);

    return $result;
}

and

 $sleep_time = 1;
 $login_wp_url = "http://www.mysite.com";
 set_time_limit(60*10);
 $result = getrequest($login_wp_url);

How do I grab contents from US-only website?

P.S. to get the idea of what I mean - try visiting the Hulu from Europe countries. P.P.S. that's not a Hulu, not a homework.

4

1 回答 1

0

许多云服务提供商,例如 Heroku 和 Amazon,免费提供他们最小的实例。您可以简单地免费设置其中一个,确保您在位于美国的服务器上进行配置并在那里运行您的脚本。

另一种可能性是对这些请求使用(免费)代理。以下是免费代理服务器列表:http ://www.xroxy.com/proxy-country-US.htm 。

curl_setopt($ch, CURLOPT_PROXY, "http://160.76.xxx.xxx:8080");
curl_setopt($ch, CURLOPT_PROXYPORT, 8080);
curl_setopt ($ch, CURLOPT_PROXYUSERPWD, "xxx:xxx");
于 2012-12-24T21:55:38.347 回答