21,886
社区成员
发帖
与我相关
我的任务
分享
<meta charset="utf-8">
<?php
$ch = curl_init();
$url='https://count.taobao.com/counter3?keys=SM_368_dsr-1097280647,ICCP_1_522177046867&callback=jsonp107';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
curl_close($ch);
preg_match_all("/(?:\()(.*)(?:\))/i", $output, $ok);
$str=$ok[1][0];
$str=str_replace('{"',"{",$str);
$str=str_replace('":',":",$str);
$str=str_replace(',"',",",$str);
//不会正则只能这样苦逼的替换了。。反正就是把他重构为json格式
$str=str_replace('{','{"',$str);
$str=str_replace(':','":',$str);
$str=str_replace(',',',"',$str);
$obj=json_decode($str);
var_dump($obj);
echo "这是你要的ICCP_1_522177046867:".$obj->ICCP_1_522177046867;
?>
<?php
//$jsonp=file_get_contents('https://count.taobao.com/counter3?keys=SM_368_dsr-1097280647,ICCP_1_522177046867&callback=jsonp107');
$jsonp='jsonp107({"SM_368_dsr-1097280647":{v:0,nv:100,m_UFB:0,m:4.89661,m_g:20.15,s_UFB:0,s:4.8744,s_g:31.49,c_UFB:0,c:4.87867,c_g:39.55,gp:100.00,ss:290159,hdr:true},"ICCP_1_522177046867":4915});';
preg_match_all('/\d{1,}/',$jsonp,$arr);
echo array_reverse($arr[0])[0];
<?php
//$jsonp=file_get_contents('https://count.taobao.com/counter3?keys=SM_368_dsr-1097280647,ICCP_1_522177046867&callback=jsonp107');
$jsonp='jsonp107({"SM_368_dsr-1097280647":{v:0,nv:100,m_UFB:0,m:4.89661,m_g:20.15,s_UFB:0,s:4.8744,s_g:31.49,c_UFB:0,c:4.87867,c_g:39.55,gp:100.00,ss:290159,hdr:true},"ICCP_1_522177046867":4915});';
preg_match_all('/\d{1,}}/',$jsonp,$arr);
echo trim($arr[0][0],'}');
$ch = curl_init();
$url='https://count.taobao.com/counter3?keys=SM_368_dsr-1097280647,ICCP_1_522177046867&callback=jsonp107';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
curl_close($ch);
echo $output;