无法使用PHP / CURL访问网站内容

时间:2016-11-23 11:53:08

标签: php curl

$ch2 = SSLCURL("https://www.tcpvpn.com/create-tcpvpn-account-server");
curl_setopt($ch2, CURLOPT_REFERER, "https://www.tcpvpn.com/free-vpn-server-continent-europe");
curl_setopt($ch2, CURLOPT_POST, 1);
curl_setopt($ch2, CURLOPT_POSTFIELDS, "server=115");
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
$ex = curl_exec($ch2);
echo nl2br(str_replace("<","!!",$ex));
curl_close($ch2);

这是我访问网站的代码。我在SSLCURL功能上处理cookie,SSL访问,重定向操作和UserAgent(最新Chrome)。

当我通过浏览器访问该网站或甚至使用Glype(用PHP编写的代理脚本)访问该网站时,我可以毫无问题地访问网站,但每次我尝试访问我的脚本时,我只是得到一个元重定向。我该如何解决?

编辑:这是SSLCURL

function SSLCURL($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_COOKIESESSION, true);
    curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__)."/jamjar.txt");
    curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__)."/jamjar.txt");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "Accept-Language:tr-TR,tr;q=0.8,en-US;q=0.6,en;q=0.4",
        "Connection:keep-alive",
        "Upgrade-Insecure-Requests:1"
        ));
    return $ch;
}

0 个答案:

没有答案