Products
GG网络技术分享 2025-03-18 16:18 0
php获取网站TDK标题API接口源码,目前只能获取标题
接口源码:
<?php
if ($_GET[\'url\']) {
$site=\'https://\';
$url=trim($site.$_GET[\'url\']);
$info=file_get_contents($url);
header(\'Content-type:text/json\');
preg_match(\'|<title>(.*?)</title>|i\',$info,$m);
if($url){
$result=array(\"code\"=>\"200\",\"title\"=>$m[1]);
echo json_encode($result,JSON_UNESCAPED_UNICODE);
}else{
$result=array(\"code\"=>\"201\",\"meg\"=>\"ERREO\");
echo json_encode($result,JSON_UNESCAPED_UNICODE);
}
}else{
$result=array(\"code\"=>\"201\",\"meg\"=>\"ERREO\");
echo json_encode($result,JSON_UNESCAPED_UNICODE);
}
?>Demand feedback