php curl ssr,php curl模拟登陆

$url="url地址";

$post_file="username=xxx&password=xxx";

$cookie_jar = dirname(__FILE__)."/pic.cookie";

$curl = curl_init();

curl_setopt( $curl,CURLOPT_URL,$url );

curl_setopt( $curl,CURLOPT_RETURNTRANSFER,true );

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);//规避证书

curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 防止302 盗链

curl_setopt($curl, CURLOPT_POSTFIELDS, $post_file);//要提交的信息

curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_jar); //设置Cookie信息保存在指定的文件中

$output = curl_exec( $curl );

curl_close( $curl );

print_r($output);

$urldata = "要操作的url带cookie的";

$post = "content=立马开始灌水啦&shopid=232";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $urldata);  //设置curl

curl_setopt($ch, CURLOPT_HEADER, false);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $post); //post数据

curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar); //读取jar

$output2 = curl_exec($ch);    //发送HTTP请求

curl_close($ch);

print_r($output2);

//获取指定页面

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_HEADER, false);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,0);

curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);

$html=curl_exec($ch);

// var_dump($html);

curl_close($ch);

@承鹏辉

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值