在线演示http://tool.ayangw.com/beian/?url=qq.com使用方法
1.创建一个php文件,比如beian.php,将下方代码复制
2.访问接口域名/beian.php?url=qq.com
PHP代码<?php
/**
* 0en.cn
*/
error_reporting(0);
$u = $_GET['url'];
var_dump();
if(!isset($u)){
echo '?url=qq.com';
die;
}
$a = file_get_contents('http://icp.chinaz.com/info?q='.$u);
$p = '/
(.*?)/';preg_match_all($p,$a,$m);
$p1 = '/
(.*?)/';preg_match($p1,$a,$m1);
$p2 = '/
(.*?)/';preg_match($p2,$a,$m2);
$p3 = '/
(.*?)/';preg_match($p3,$a,$m3);
$p4 = '/
(.*?)/is';preg_match($p4,$a,$m4);
$p5 = '/
(.*?)/';preg_match_all($p5,$a,$m5);
$data['备案号'] = $m[1][0];
$data['网站名称'] = $m[1][1];
$data['审核时间'] = $m1[1];
$data['主办单位'] = $m2[1];
$data['主办单位性质'] = $m3[1];
$data['网站首页地址'] = $m4[1];
$data['网站备案/许可证号'] = $m5[1][1];
if(strpos($m[0][0],'-') == 41){
$arr = ['code'=>500,'msg'=>'未备案'];
print_r(json_encode($arr,JSON_UNESCAPED_UNICODE));
}else{
print_r(json_encode($data,JSON_UNESCAPED_UNICODE));
}