PHP code example of php127 / websiteinfo

1. Go to this page and download the library: Download php127/websiteinfo library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

php127 / websiteinfo example snippets


use Php127\WebsiteInfo;

$str = file_get_contents('http://www.test.com');

$webinfo = new WebsiteInfo($str);


$webinfo->get();

/*
Array
(
    [name] => 网站名称
    [title] => test标题
    [keywords] => test关健词
    [description] => test描述
    [logo] => Array
        (
            [0] => https://www.test.com/images/logo.svg
            [1] => https://www.test.com/images/logo.svg
        )

    [icon] => 
    [qq] => Array
        (
            [0] => 1231230
        )

    [beian] => 沪ICP备202xxx722号-1
    [security] => 皖公网安备 340xxx000334号
    [isCnzzTongji] => 
    [isBaiduTongji] => 1
    [isWuyilaTongji] => 1
)
*/


//获取网站名称
$webinfo->getName();

//获取网站title
$webinfo->getTitle();

//获取网站keywords
$webinfo->getKeywords();

//获取网站description
$webinfo->getDescription();

//获取网站logo
$webinfo->getLogo();

//获取网站icon
$webinfo->getIcon();

//获取网站ICP备案号
$webinfo->getBeian();

//获取网站公安备案号
$webinfo->getSecurity();

//获取网站联系QQ
$webinfo->getQQ();

//获取网站联系微信
$webinfo->getWeixin();

//获取网站联系邮箱
$webinfo->getEmail();

//网站是否使用cnzz统计
$webinfo->isCnzzTongji();

//网站是否使用百度统计
$webinfo->isBaiduTongji();

//网站是否使用51.la统计
$webinfo->isWuyilaTongji();

$str = file_get_contents('http://www.test2.com');

//当同时分析多个页面时,无需再次new WebsiteInfo
$webinfo->setHtml($str);
$webinfo->getLogo();
//...