curl远程获取验证码
-
$CookieFile=tempnam("./tmep","beast");
- if(isset($_GET["img"])){
- $url = 'http://www.yto.net.cn/Controller/ValidateCode.aspx';//验证码code
- $ch = curl_init($url);
- curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);//把返回来的cookie信息保存在文件中
- curl_exec($ch);
- curl_close($ch);
- exit();
- }
- if(isset($_POST['d'])){
- $b=$_POST[d];//验证码
- $p="waybillNo=1721269381&inputcode=".$b;
- $ch = curl_init();
- // 2. 设置选项,包括URL
- curl_setopt($ch,CURLOPT_URL, "http://jingang.yto56.com.cn/expws/expquery/waybillService.action");
- curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);
- curl_setopt($ch,CURLOPT_COOKIEFILE, $CookieFile);//同时发送Cookie
- curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch,CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_POSTFIELDS, $p);//提交查询信息
- $s = curl_exec($ch);
- curl_close($ch);
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_URL, "http://jingang.yto56.com.cn/expws/expquery/waybillService.action");
- curl_setopt($ch,CURLOPT_COOKIEFILE, $CookieFile);//同时发送Cookie
- curl_setopt($ch,CURLOPT_COOKIEJAR, $CookieFile);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch,CURLOPT_POST, 1);
- curl_setopt($ch,CURLOPT_POSTFIELDS, $p);//提交查询信息
- $bs = curl_exec($ch);
- echo $bs;//输出结果
- curl_close($ch);
- }else{
- ?>
-
?>
复制代码
|