搜索您想要的文章


PHP获取网站标题 描述 关键字代码,无需第三方接口

作者:Admin采集插件 时间:2023-04-08 浏览:621 分类:php教程 来源:互联网收录

原生PH获取标题(title)、描述(description)、关键字(keywords)代码,无需第三方API接口。

<?php
header("content-type:text/html; charset=utf8");
$arr = file("http://www.zidongcaiji.com");
if($arr){
    foreach($arr as $a){
        if(strchr($a,"<title>")){
            $a = str_ireplace("<title>","",$a);
            $a = str_ireplace("</title>","",$a);
            echo $a;//标题
            break;
        }
    }
}
$meta_array = get_meta_tags('http://www.dedecmsok.com');
echo $meta_array["keywords"];//关键词
echo $meta_array["description"];//描述
?>

如果使用PHP.ini默认配置,用file_get_contents读取https的链接,就会如下错误:

Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?

解决方案:

1、php.ini中把extension=php_openssl.dll前面的;删掉,重启服务就可以了。

2、Linux下的PHP,安装openssl模块,安装好了以后就可以访问了。

3、如果不能修改配置,就只换curl函数来替代file_get_contents函数。


本文章来自互联网,有问题请联系QQ:1739635


免责声明:1.凡本站注明“来源:XXX(非CMS自动采集助手)”的作品,均转载自其它媒体,所载的文章、图片、音频视频文件等资料的版权归版权所有人所有,如有侵权,请联系[email protected]处理;2.凡本站转载内容仅代表作者本人观点,与CMS自动采集助手无关。