php实现专业获取网站SEO信息类实例
发布时间:2020-05-23 23:58:59 所属栏目:PHP 来源:互联网
导读:这篇文章主要介绍了php实现专业获取网站SEO信息类,实例分析了seoreport类针对网站SEO信息检查与获取的技巧,非常具有实用价值,需要的朋友可以参考下
|
本文实例讲述了php实现专业获取网站SEO信息类。分享给大家供大家参考。具体如下: 这个SEO类的功能包括: - 检查指定的网站响应 - 获取从该网站主页的语言和其他meta标签数据的 - 获取网站的导入链接,从Alexa的流量排名 - 获取网站的导入链接,由谷歌索引的网页数量 - 获取网站的信任,从WOT排名。 - 获取,因为它是第一个注册的网站域名年龄 - 获取的Twitter网站页面的数量 - 获取的Facebook链接的网站页面 - 获取网站谷歌网页速度等级 - 获取网站的谷歌网页排名
* @copyright (c) 2009-2012 Open Classifieds Team
* @license GPL v3
* Based on SEO report script http://www.phpeasycode.com && PHP class SEOstats
*
*/
class SEOreport{
/**
*
* check if a url is online/alive
* @param string $url
* @return bool
*/
public static function is_alive($url)
{
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_BINARYTRANSFER,1);
curl_setopt($ch,CURLOPT_HEADERFUNCTION,'curlHeaderCallback');
curl_setopt($ch,CURLOPT_FAILONERROR,1);
curl_exec ($ch);
$int_return_code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close ($ch);
if ($int_return_code != 200 && $int_return_code != 302 && $int_return_code != 304)
{
return FALSE;
}
else return TRUE;
}
/**
* HTTP GET request with curl.
*
* @param string $url String,containing the URL to curl.
* @return string Returns string,containing the curl result.
*
*/
protected static function get_html($url)
{
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,CURLOPT_CONNECTTIMEOUT,5);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,CURLOPT_MAXREDIRS,2);
if(strtolower(parse_url($url,PHP_URL_SCHEME)) == 'https')
{
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,1);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,1);
}
$str = curl_exec($ch);
curl_close($ch);
return ($str)?$str:FALSE;
}
/**
*
* get the domain from any URL
* @param string $url
*/
public static function domain_name($url)
{
$nowww = ereg_replace('www.','',$url);
$domain = parse_url($nowww);
if(!empty($domain["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);
}
/**
|
