当前位置:Gxlcms > PHP教程 > curl远程获取验证码

curl远程获取验证码

时间:2021-07-01 10:21:17 帮助过:3人阅读

curl远程获取验证码
  1. $CookieFile=tempnam("./tmep","beast");
  2. if(isset($_GET["img"])){
  3. $url = 'http://www.yto.net.cn/Controller/ValidateCode.aspx';//验证码code
  4. $ch = curl_init($url);
  5. curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);//把返回来的cookie信息保存在文件中
  6. curl_exec($ch);
  7. curl_close($ch);
  8. exit();
  9. }
  10. if(isset($_POST['d'])){
  11. $b=$_POST[d];//验证码
  12. $p="waybillNo=1721269381&inputcode=".$b;
  13. $ch = curl_init();
  14. // 2. 设置选项,包括URL
  15. curl_setopt($ch,CURLOPT_URL, "http://jingang.yto56.com.cn/expws/expquery/waybillService.action");
  16. curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);
  17. curl_setopt($ch,CURLOPT_COOKIEFILE, $CookieFile);//同时发送Cookie
  18. curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
  19. curl_setopt($ch,CURLOPT_POST, 1);
  20. curl_setopt($ch,CURLOPT_POSTFIELDS, $p);//提交查询信息
  21. $s = curl_exec($ch);
  22. curl_close($ch);
  23. $ch = curl_init();
  24. curl_setopt($ch,CURLOPT_URL, "http://jingang.yto56.com.cn/expws/expquery/waybillService.action");
  25. curl_setopt($ch,CURLOPT_COOKIEFILE, $CookieFile);//同时发送Cookie
  26. curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);
  27. curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
  28. curl_setopt($ch,CURLOPT_POST, 1);
  29. curl_setopt($ch,CURLOPT_POSTFIELDS, $p);//提交查询信息
  30. $bs = curl_exec($ch);
  31. echo $bs;//输出结果
  32. curl_close($ch);
  33. }else{
  34. ?>
  35. ?>

人气教程排行