首页 > 其他分享 >curl模拟登录

curl模拟登录

时间:2023-02-01 13:02:51浏览次数:33  
标签:www ch setopt 登录 CURLOPT curl data 模拟

$post_data = array("username"=>"[email protected]","password"=>"yuejide198225","remember"=>0); 
$data = http_build_query($post_data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.imooc.com/user/login");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);//不要直接输出

date_default_timezone_set('PRC');
curl_setopt($ch, CURLOPT_COOKIESESSION,1);
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支持页面跳转
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=utf8","Content-length:".strlen($data)));
curl_exec($ch);//执行
curl_setopt($ch, CURLOPT_URL, "http://www.imooc.com/space/index");
curl_setopt($ch, CURLOPT_POST,0);
curl_setopt($ch, CURLOPT_HTTPHEADER,array("Content-type:text/html"));
$output = curl_exec($ch);
curl_close($ch);
//打印数据
echo $output;

 



标签:www,ch,setopt,登录,CURLOPT,curl,data,模拟
From: https://blog.51cto.com/u_2820398/6031402

相关文章

  • java 模拟输入
    packagecn.net.haotuo;importcom.sun.jna.platform.win32.BaseTSD;importcom.sun.jna.platform.win32.User32;importcom.sun.jna.platform.win32.WinDef;importcom.sun......
  • Hive 刷题——查询每个用户登录日期的最大空档期
    需求描述从登录明细表(user_login_detail)中查询每个用户两个登录日期(以login_ts为准)之间的最大的空档期。统计最大空档期时,用户最后一次登录至今的空档也要考虑在内,假设今......
  • 登录注册案例
    需求说明:完成用户登录功能,如果用户勾选“记住用户”,则下次访问登录页面自动填充用户名密码完成注册功能,并实现验证码功能记住用户如果用户勾选“记住用户”,则下次访问登......
  • 模拟DBUtils中的queryRunner.query()的反射机制的模拟
    本文主要是讲述对于DBUtils中的queryRunner.query(connection,sql,newBeanListHandler<>(Admin.class))的模拟代码结构: DBUtilsReflection类:/***将查询到的结果......
  • ubuntu初始化登录jenkins提示Error错误
    安装环境:jdk使用的是二进制安装的jdk11https://www.oracle.com/java/technologies/downloads/#java11jenkins使用的是jenkins2.2774(deb包)版本https://mirrors.jenk......
  • 2022-2023 ICPC Asia East - Shenyang Regional Contest - 校内模拟总结
    我菜死了A显然重叠部分积分\(\frac{1}{3}\),前面的积分累加就行。仔细思考题目,主要是好久没做题了。B不会,神秘题,咕咕咕C随便什么做法都能过D???E树形背包后容斥,套......
  • vue+springboot集成钉钉扫码登录
    具体接入方式可参考官方介绍:https://open.dingtalk.com/document/orgapp-server/tutorial-obtaining-user-personal-information本文只演示vue+springboot如何实现钉钉扫......
  • docker仓库登录出错
    Errorsavingcredentials:errorstoringcredentials-err:exitstatus1,CannotautolaunchD-BuswithoutX11$DISPLAY`出错提示:errorstoringcredentials-er......
  • 接口测试|postman模拟请求头&界面的响应信息
    ## postman模拟请求头&界面的响应信息### postman模拟请求头页面访问请求(get方法):https://www.baidu.com/s?wd=猫  该https请求在页面上可以进行根据最后的关键字参数进......
  • 登录案例_BeanUtils基本使用与登录案例_BeanUtils介绍
    登录案例_BeanUtils基本使用  BeanUtils工具类,简化数据封装//2.获取所有请求参数Map<String,String[]>map=request.getParameterMap();......