问答详情
源自:2-4 用cURL登陆慕课网并下载个人空间页面

curl无法登陆慕课

为什么我的也不行啊,求 分享个连接成功的,或者老师,重新上传一份文件

提问者:lu在脚下 2015-10-30 01:30

个回答

  • 慕移动9181930
    2022-03-27 12:03:59

    当然可以了。使'

  • qq_果冻_4
    2016-10-01 11:18:32

    <?php


    /*

    查看慕课网某用户的课程信息

    */


    $data = 'email= &password=&remember=1';


    $ch = curl_init();


    curl_setopt($ch, CURLOPT_URL, "http://www.imooc.com");


    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //保存结果 不输出


    date_default_timezone_set('PRC'); //设置时区


    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);  //不使用认证


    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);  //不使用认证


    curl_setopt($ch, CURLOPT_COOKIESESSION, true);


    curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile");


    curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile");


    curl_setopt($ch, CURLOPT_COOKIE, session_name(). '=' . session_id());


    curl_setopt($ch, CURLOPT_HEADER, 0);


    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //支持页面跳转




    curl_setopt($ch, CURLOPT_POST, 1);


    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);


    curl_setopt($ch, CURLOPT_HTTPHEADER, array("application/x-www-form-urlencoded;charset=utf-8","Content-Length: " . strlen($data)));


    curl_exec($ch);


    curl_setopt($ch, CURLOPT_URL, "http://www.imooc.com/u/2985311/courses");


    curl_setopt($ch, CURLOPT_POST, 0);


    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: text/xml"));


    $output = curl_exec($ch);


    curl_close($ch);


    echo $output;

    ?>


  • 乔帮主
    2015-10-30 15:50:43

    http://blog.csdn.net/whq19890827/article/details/46654501你看下这里面的吧,不知道对你有帮助没!

  • lu在脚下
    2015-10-30 01:31:25

    或者同伴们贴一下代码