PHP中的cURL不';不要总是遵循重定向

PHP中的cURL不';不要总是遵循重定向,php,curl,brute-force,Php,Curl,Brute Force,我有以下代码: for($i = $start; $i <= $end ; $i++) { $url = "http://xxx.co.il/yyy?zzz=$i"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows

我有以下代码:

for($i = $start; $i <= $end ; $i++)
    {
        $url = "http://xxx.co.il/yyy?zzz=$i";
        $ch = curl_init();
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; he-IL; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
        curl_setopt ($ch, CURLOPT_REFERER, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        $result = curl_exec($ch);
        $info = curl_getinfo($ch);
        curl_close($ch);

        if($info['url'] == "http://www.xxx.co.il/abc")
        {
                echo "<br />%^$i^%<br />";   
        }
        else
        {
                echo "$info['url']";
        }

对于($i=$start;$i一个常见的循环重定向陷阱是您的客户端需要管理cookie:

尝试添加以下选项:

curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");

cookies实际上阻止我尝试使用多个变量来获取变量。当我关闭cURL连接时,它会在下次循环运行时清除cookies吗?不会,但您可以在
cURL\u init()之前使用
unlink(“cookies.txt”)
。还请记住,它以前一直有效,我发现该文件的一个旧版本现在也有同样的问题。我相信它与WAMPI有关。不过我会尝试一下。它没有解决问题:(