donglv6747 2019-06-05 06:50
浏览 60

尝试将站点抓取到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"

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 个人网站被恶意大量访问,怎么办
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制