MENU

PHP获取网站标题接口源码

接口演示

1.png

接口简介

获取任意网站的标题 只是标题 只是标题 只是标题 重要的事情说三遍 不能获取关键词和描述 只是网站的标题 接口源码暂时不支持ssl的网站 

接口代码

<?php
if ($_GET['url']) {
    $site='http://';
    $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);
}
?>
0:00