网站首页 >> 源码大全 >> 正文
标题

PHP获取网页标题和内容信息接口

小小   2025-03-20 10:53:26   39℃   0
内容

PHP获取网页标题和内容信息接口

PHP获取网页标题和内容信息接口

$url = filter(ge[文]t('ur[章]l'));[来]

if (!$url) {

    return json([[自]9;code[就]9; => -1, 'msg&[爱]#39; => '链接不能[技]为空!'][术]);

} else if (get_curl[网]($url) === false) {

    return json([[文]9;code[章]9; => -1, 'msg&[来]#39; => '提交的网[自]址无法访问![就]9;]);

}

$data = get_curl([爱]$url);

//Title

preg_matc[技]h('/&[术]lt;TITLE&[网]gt;([\w\W[文]]*?)<\[章]/TITLE>[来];/si'[自], $data, $Title);

if (!empty($[就]Title[1])[爱]) {

    $title = $Title[1][技];

}

//Keyword[术]s

preg_matc[网]h('/&[文]lt;META\s[章]+name=&qu[来]ot;keywor[自]ds"\[就]s+content[爱]="([[技]\w\W]*?)&[术]quot;/si&[网]#39;, $data, $Keywords[文]);

if (empty($K[章]eywords[1[来]])) {

    preg_matc[自]h("/[就]<META\[爱]s+name=&#[技]39;keywor[术]ds'\s[网]+content=[文]'([\w[章]\W]*?)[来]9;/si&quo[自]t;, $data, $Keywords[就]);

}

if (empty($K[爱]eywords[1[技]])) {

    preg_matc[术]h('/&[网]lt;META\s[文]+content=[章]"([\[来]w\W]*?)&q[自]uot;\s+na[就]me="[爱]keywords&[技]quot;/si&[术]#39;, $data, $Keywords[网]);

}

if (empty($K[文]eywords[1[章]])) {

    preg_matc[来]h('/&[自]lt;META\s[就]+http-equ[爱]iv="[技]keywords&[术]quot;\s+c[网]ontent=&q[文]uot;([\w\[章]W]*?)&quo[来]t;/si'[自];, $data, $Keywords[就]);

}

if (!empty($[爱]Keywords[[技]1])) {

    $keywords[术] = $Keywords[网][1];

}

//Description

preg_matc[文]h('/&[章]lt;META\s[来]+name=&qu[自]ot;descri[就]ption&quo[爱]t;\s+cont[技]ent="[术];([\w\W]*[网]?)"/[文]si', $data, $Descript[章]ion);

if (empty($D[来]escriptio[自]n[1])) {

    preg_matc[就]h("/[爱]<META\[技]s+name=&#[术]39;descri[网]ption'[文];\s+conte[章]nt='([来][\w\W]*?)[自]'/si&[就]quot;, $data, $Descript[爱]ion);

}

if (empty($D[技]escriptio[术]n[1])) {

    preg_matc[网]h('/&[文]lt;META\s[章]+content=[来]"([\[自]w\W]*?)&q[就]uot;\s+na[爱]me="[技]descripti[术]on"/[网]si', $data, $Descript[文]ion);

}

if (empty($D[章]escriptio[来]n[1])) {

    preg_matc[自]h('/&[就]lt;META\s[爱]+http-equ[技]iv="[术]descripti[网]on"\[文]s+content[章]="([[来]\w\W]*?)&[自]quot;/si&[就]#39;, $data, $Descript[爱]ion);

}

if (!empty($[技]Descripti[术]on[1])) {

    $descript[网]ion = $Descript[文]ion[1];

}

if ($Title[1[章]] !== "&qu[来]ot;) {

    dataLog(&[自]#39;URL[&[就]#39;.$url[爱].发布单页信息获取[技]成功!',[术]'1[网]9;,'1[文]');

    $result = array([章]9;code[来]9;=>0,[自]'msg&[就]#39;=>[爱]'获取成功[技]!',&#[术]39;title&[网]#39;=>[文]$title,&#[章]39;keywor[来]ds'=&[自]gt;$keywo[就]rds,'[爱]descripti[技]on'=&[术]gt;$descr[网]iption);

} else {

    $result = array([文]9;code[章]9;=>-1[来],'msg[自]'=>[就];'站点信[爱]息获取失败![技]9;);

}

if (json_enc[术]ode($resu[网]lt) === false) {

    return json([[文]9;code[章]9; => -1, 'msg&[来]#39; => '站点信息[自]获取失败!'[就];]);

} else {

    return json($res[爱]ult);

}


文章版权声明
1 本网站名称:就爱技术网2 本站永久网址:http://jajsw.com3 本网站的文章部分内容来源于网络,仅供大家学习与参考,如有侵权,请联系站长 QQ进行删除处理。4 本站资源仅供学习和交流使用,版权归原作者所有,请在下载后24小时之内自觉删除。5 本站大部分下载资源收集于网络,不保证其完整性以及安全性,不提供技术支持,请下载后自行研究。6 若作商业用途,请购买正版,由于未及时购买和付费发生的侵权行为,使用者自行承担,概与本站无关。
点评

本文暂无评论 - 欢迎您

用户中心

快捷导航返回顶部
提交收录
广告合作
返回顶部