相思资源网 Design By www.200059.com
本文实例讲述了php实现专业获取网站SEO信息类。分享给大家供大家参考。具体如下:
这个seo类的功能包括:
- 检查指定的网站响应
- 获取从该网站主页的语言和其他meta标签数据的
- 获取网站的导入链接,从Alexa的流量排名
- 获取网站的导入链接,由谷歌索引的网页数量
- 获取网站的信任,从WOT排名。
- 获取,因为它是第一个注册的网站域名年龄
- 获取的Twitter网站页面的数量
- 获取的Facebook链接的网站页面
- 获取网站谷歌网页速度等级
- 获取网站的谷歌网页排名
<"host"])) return $domain["host"]; else return $domain["path"]; } /** * * get the metas from a url and the language of the site * @param string $url * @return array */ public static function meta_info($url) { //doesn't work at mediatemple /*$html = new DOMDocument(); if(!$html->loadHtmlFile($url)) return FALSE;*/ if (!$html_content = self::get_html($url)) return FALSE; $html = new DOMDocument(); $html->loadHtml($html_content); $xpath = new DOMXPath( $html ); $url_info = array(); $langs = $xpath->query( '//html' ); foreach ($langs as $lang) { $url_info['language'] = $lang->getAttribute('lang'); } $metas = $xpath->query( '//meta' ); foreach ($metas as $meta) { if ($meta->getAttribute('name')) { $url_info[$meta->getAttribute('name')] = $meta->getAttribute('content'); } } return $url_info; } /** * * Alexa rank * @param string $url * @return integer */ public static function alexa_rank($url) { $domain = self::domain_name($url); $request = "http://data.alexa.com/data" . $domain; $data = self::get_html($request); preg_match('/<POPULARITY URL="(.*" TEXT="([\d]+)"\/>/si', $data, $p); return ($l[2]) "http://data.alexa.com/data" . $domain; $data = self::get_html($request); preg_match('/<LINKSIN NUM="([\d]+)"\/>/si', $data, $l); return ($l[1]) "http://www.google.com/search" . urlencode("link:" . $url) . "&hl=en"; $data = self::get_html($request); preg_match('/<div id=resultStats>(About )"http://api.mywot.com/0.4/public_query2" . $domain; $data = self::get_html($request); preg_match_all('/<application name="(\d+)" r="(\d+)" c="(\d+)"\/>/si', $data, $regs); $trustworthiness = ($regs[2][0]) "http://reports.internic.net/cgi/whois" . $domain . "&type=domain"; $data = self::get_html($request); preg_match('/Creation Date: ([a-z0-9-]+)/si', $data, $p); return (!$p[1])"http://urls.api.twitter.com/1/urls/count.json"; $fileData = file_get_contents(sprintf($twitterEndpoint, $url)); $json = json_decode($fileData, true); unset($fileData); // free memory return (is_numeric($json['count']))"http://toolbarqueries.google.com/tbr".self::CheckHash(self::HashURL($url)). "&features=Rank&q=info:".$url."&num=100&filter=0"; $data = self::get_html($query);//die(print_r($data)); $pos = strpos($data, "Rank_"); if($pos === false) { return NULL; } else { $pagerank = substr($data, $pos + 9); return $pagerank; } } // functions for google pagerank /** * To calculate PR functions */ public static function StrToNum($Str, $Check, $Magic) { $Int32Unit = 4294967296; // 2^32 $length = strlen($Str); for ($i = 0; $i < $length; $i++) { $Check *= $Magic; //If the float is beyond the boundaries of integer (usually +/- 2.15e+9 = 2^31), // the result of converting to integer is undefined // refer to http://www.php.net/manual/en/language.types.integer.php if ($Check >= $Int32Unit) { $Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit)); //if the check less than -2^31 $Check = ($Check < -2147483648) "htmlcode"><?php include 'seoreport.php'; ini_set('max_execution_time', 180); $url = (isset($_GET['url']))?$_GET['url']:'http://phpclasses.org'; $meta_tags = seoreport::meta_info($url); //die(var_dump($meta_tags)); //first check if site online if ($meta_tags!==FALSE) { $stats = array(); $stats['meta'] = $meta_tags; $stats['alexa']['rank'] = seoreport::alexa_rank($url); $stats['alexa']['links'] = seoreport::alexa_links($url); $stats['domain']['WOT_rating'] = seoreport::WOT_rating($url); $stats['domain']['domain_age'] = seoreport::domain_age($url); $stats['social']['twitter'] = seoreport::tweet_count($url); $stats['social']['facebook'] = seoreport::facebook_shares($url); $stats['google']['page_rank'] = seoreport::page_rank($url); $stats['google']['page_speed'] = seoreport::page_speed($url); $stats['google']['pages'] = seoreport::google_pages($url); $stats['google']['links'] = seoreport::google_links($url); var_dump($stats); } else 'Site not online. '.$url;希望本文所述对大家的php程序设计有所帮助。
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无php实现专业获取网站SEO信息类实例的评论...