[PHP] php 抓取网站seo 信息 →→→→→进入此内容的聊天室

来自 , 2019-12-24, 写在 PHP, 查看 105 次.
URL http://www.code666.cn/view/4db0f8b0
  1. <?php
  2. header("Content-type:text/html; charset=utf-8");
  3. echo'<link rel="Stylesheet" type="text/css" href="toolsite.css?ver=2011_11"/>';  
  4. $check_html="<center><form action='tseo.php' method='post'><font>请输入网址:</font>http://<span class=s_ipt_wr><input type=text name=ck_url class=s_ipt></span><input type=submit name=ck_tj value=查询  class=s_btn></form></center>";
  5. class seo_Check{
  6.     public $url;
  7.  
  8.     function __construct($url){
  9.         $this->url=$url;
  10.             }
  11.  
  12.     function show_seo(){
  13.         $this->check_url();
  14.         $this->get_content();
  15.             }
  16.  
  17.     function check_url(){  
  18.         $zurl=$this->url;
  19.         if(!empty($zurl)){          
  20.         $pattern="/^(http\\:\\/\\/)?(www)?\\.([0-9a-z]+)\\.(com|cn|net|com\\.cn)$/i";        
  21.         if(preg_match($pattern,$zurl,$newurl)){
  22.  
  23.             if(!empty($newurl[1])){
  24.             $zurl=trim($newurl[1].".".$newurl[2].".".$newurl[3].".".$newurl[4]);
  25.             //$this->url=$zurl;
  26.             }
  27.  
  28.          }
  29.          else          
  30.          {  
  31.             die("网址不合法!");
  32.          }
  33.     }
  34.  
  35.     }
  36.  
  37.     //get_content()
  38. function get_content(){    
  39. $strem="http://seo.chinaz.com/?host=".$this->url;
  40. //echo $strem;
  41. $contents=file_get_contents($strem);          // file_get_contents获取内容
  42. if (!preg_match("<html>",$contents)){         // 暂时这样测试匹配成功与否
  43.      die("内容失效");                          
  44. }
  45.  
  46. $contents=str_replace("\\n",'',$contents);
  47. $contents=str_replace("/template/default/images",'http://seo.chinaz.com/template/default/images',$contents);
  48.  
  49. preg_match("/\\<table (.*?)\\>(.*?)\\<\\/table\\>/i",$contents,$newcode);
  50.  
  51. $_infohtml="<center><table class='info_tab'>".$newcode[2]."</table></center>";
  52.  
  53. echo $_infohtml;
  54.     }  
  55. }
  56.  
  57. if ($_POST['ck_tj']){  
  58.  
  59.     if(!empty($_POST['ck_url'])){
  60. $ck_url=$_POST['ck_url'];
  61. $show_seo1=new seo_Check($ck_url);
  62. $show_seo1->show_seo();
  63.     }
  64. }else
  65.     {
  66.         $ck_url="";
  67.         echo $check_html;
  68.     }
  69.  
  70. //echo $show_seo1->cur_html;
  71. ?>
  72. //该片段来自于http://yuncode.net
  73.  

回复 "php 抓取网站seo 信息"

这儿你可以回复上面这条便签

captcha