PHP获取网站TDK标题API接口源码,目前只能获取标题,不能获取关键词和描述,暂不支持ssl的网站。
接口代码
<?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);
}
?>本文转载自:精准像素:11px.cn ,感谢作者分享实用知识
