标签:pos style create ade url ucs lse 验证 输出
//json乱码转中文
function decodeUnicode($str){ return preg_replace_callback(‘/\\\\u([0-9a-f]{4})/i‘, create_function( ‘$matches‘, ‘return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE");‘ ), $str); }
curl爬虫
function _grab($curl,$postInfo=‘‘,$cookie=‘‘,$referer=‘‘,$userAgent=‘‘){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $curl); //不输出头 curl_setopt($ch, CURLOPT_HEADER, 0); //以字符串返回获取的信息,不直接输出 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //如果是https链接,不验证证书 if(preg_match(‘/https/i‘, $curl)){ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } //POST if($postInfo){ curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$postInfo); } //加入cookie if($cookie){ curl_setopt($ch,CURLOPT_COOKIE,$cookie); } //模拟来路 if($referer){ curl_setopt($ch, CURLOPT_REFERER, $referer); } //模拟环境 if($userAgent){ curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); } //执行 $content = curl_exec($ch); //错误处理 if ($content === false) { return "网络请求出错: " . curl_error($ch); exit(); } return $content; }
标签:pos style create ade url ucs lse 验证 输出
原文地址:https://www.cnblogs.com/cl94/p/9606524.html