PHP新型冠状病毒API接口代码
<?php $a = file_get_contents("https://3g.dxy.cn/newh5/view/pneumonia"); $b = getSubstr($a,'window.getTimelineService = ','}catch(e){}');//实时热点 $c = getSubstr($a,'window.getAreaStat = ','}catch(e){}');//国内 $d = getSubstr($a,'window.getListByCountryTypeService2 = ','}catch(e){}');//国外 $e = getSubstr($a,'window.getStatisticsService = ','}catch(e){}');//统计 $f = json_decode($e, true); echo '{"data": ['.'{"result": '.$b.'},'.'{"China": '.$c.'},'.'{"abroad": '.$d.'},'.$e.']}'; function getSubstr($str, $leftStr, $rightStr){ $left = strpos($str, $leftStr); $right = strpos($str, $rightStr,$left); if($left < 0 or $right < $left) return ''; return substr($str, $left + strlen($leftStr), $right-$left-strlen($leftStr)); } ?>
资源均来自第三方,谨慎下载,前往第三方网站下载