尝试将站点抓取到localhost服务器上,但页面卡在重定向页面上

Im trying to create a script using cUrl and php to login to a site and scrape data from logged in page. But whenever i try to grab the site the page is stuck in the redirection page. I used curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);. Didnt work.

I used curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);. Didnt work. Used the same function on different sites and it worked just fine. Below is the code i used to grab the page.

function grab_page($site){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($ch, CURLOPT_TIMEOUT, 40  );
    curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
    curl_setopt($ch, CURLOPT_URL, $site);
    ob_start();
    if(curl_exec ($ch)==FALSE){
      echo "Curl Error: ".curl_error($ch);
    }
    return curl_exec ($ch);
    ob_end_clean();
    curl_close ($ch);
}

The function is supposed to grab the page https://www.khanbank.com/mn/personal so i can echo it out to a page. But what i get is just a blank page that reads "redirecting please wait a moment"