php正则获取网页标题、关键字、网页描述代码
来源:互联网 发布:java高级编程 jb51 编辑:程序博客网 时间:2024/06/05 19:49
php正则获取网页关键字,代码如下:
function get_keywords($html)
{
$html=strtolower($html);
preg_match("@<head[^>]*>(.*?)</head>@si",$html, $regs);
$headdata = $regs[1];
preg_match("/<meta +name *=["']?keywords["']? *content=["']?([^<>"]+)["']?/i", $headdata, $res);
if (isset ($res)) {
$keywords = $res[1];
}
if ($keywords == "") $keywords = "无";
$keywords=replace_word(textcut($keywords,250));
$keywords=str_replace("-",",",$keywords);
$keywords=str_replace(",",",",$keywords);
$keywords=str_replace(" ",",",$keywords);
$keywords=str_replace("|",",",$keywords);
$keywords=str_replace("、",",",$keywords);
$keywords=str_replace(",,",",",$keywords);
$keywords=str_replace("<","",$keywords);
$keywords=str_replace(">","",$keywords);
return addslashes(trim($keywords));
}
php正则获取网页标题,代码如下
function get_title($html)
{
$html=strtolower($html);
$title = str_replace(" - ",",",cut($html,"<title>", "</title>" ));
//if ($title == "") $title = "无标题";
if ($title) $title=replace_word(textcut($title,80));
if ($title) $title=preg_replace("/<(.*?)>/","",$title);
return addslashes(trim($title));
}
php正则获取网页描述description,代码如下
function get_description($html)
{
$html=strtolower($html);
preg_match("@<head[^>]*>(.*?)</head>@si",$html, $regs);
$headdata = $regs[1];
preg_match("/<meta +name *=["']?description["']? *content=["']?([^<>"]+)["']?/i", $headdata, $res);
if (isset ($res)) {
$description = $res[1];
}
if ($description == "") $description = "无";
$description=replace_word(textcut($description,250));
$description=str_replace("-",",",$description);
$description=str_replace(",",",",$description);
$description=str_replace(" ",",",$description);
$description=str_replace("|",",",$description);
$description=str_replace("、",",",$description);
$description=str_replace(",,",",",$description);
$description=str_replace("<","",$description);
$description=str_replace(">","",$description);
return addslashes(trim($description));
}
(责任编
function get_keywords($html)
{
$html=strtolower($html);
preg_match("@<head[^>]*>(.*?)</head>@si",$html, $regs);
$headdata = $regs[1];
preg_match("/<meta +name *=["']?keywords["']? *content=["']?([^<>"]+)["']?/i", $headdata, $res);
if (isset ($res)) {
$keywords = $res[1];
}
if ($keywords == "") $keywords = "无";
$keywords=replace_word(textcut($keywords,250));
$keywords=str_replace("-",",",$keywords);
$keywords=str_replace(",",",",$keywords);
$keywords=str_replace(" ",",",$keywords);
$keywords=str_replace("|",",",$keywords);
$keywords=str_replace("、",",",$keywords);
$keywords=str_replace(",,",",",$keywords);
$keywords=str_replace("<","",$keywords);
$keywords=str_replace(">","",$keywords);
return addslashes(trim($keywords));
}
php正则获取网页标题,代码如下
function get_title($html)
{
$html=strtolower($html);
$title = str_replace(" - ",",",cut($html,"<title>", "</title>" ));
//if ($title == "") $title = "无标题";
if ($title) $title=replace_word(textcut($title,80));
if ($title) $title=preg_replace("/<(.*?)>/","",$title);
return addslashes(trim($title));
}
php正则获取网页描述description,代码如下
function get_description($html)
{
$html=strtolower($html);
preg_match("@<head[^>]*>(.*?)</head>@si",$html, $regs);
$headdata = $regs[1];
preg_match("/<meta +name *=["']?description["']? *content=["']?([^<>"]+)["']?/i", $headdata, $res);
if (isset ($res)) {
$description = $res[1];
}
if ($description == "") $description = "无";
$description=replace_word(textcut($description,250));
$description=str_replace("-",",",$description);
$description=str_replace(",",",",$description);
$description=str_replace(" ",",",$description);
$description=str_replace("|",",",$description);
$description=str_replace("、",",",$description);
$description=str_replace(",,",",",$description);
$description=str_replace("<","",$description);
$description=str_replace(">","",$description);
return addslashes(trim($description));
}
(责任编
阅读全文
0 0
- php正则获取网页标题、关键字、网页描述代码
- PHP获取网页标题的代码
- 《如何设置网页标题关键字和描述》讲课记录下载
- 给asp.net 网页添加标题、关键字、描述本文
- ASP.NET C# 动态设置网页标题、关键字、描述
- ASP.NET C# 动态设置网页标题、关键字、描述
- PHP 正则表达式 获取网页charset 编码 ,可以获取任意网页charset(代码备份)
- 获取网页标题的代码-asp
- C# 获取网页标题title的代码
- HTMLPARSER 爬取 html网页 获取标题 关键字 内容 url
- 获取网页的标题
- 获取网页标题
- webview获取网页标题
- [PHP代码] PHP远程获取网页内容
- php 获取网页内容及代码
- CURL获取网页(PHP代码函数)
- libcurl获取网页内容的PHP代码
- 利用PHP获取网页的源代码或标题
- java 文件下载,中文表名,中文内容
- editor.md 本地上传图片
- IP子网划分
- Tensorflow Anaconda4.2 Cudnn
- ES6 新特性范例大全
- php正则获取网页标题、关键字、网页描述代码
- iOS开发之代码约束
- lua-Texture2D纹理缓存的加载
- Leetcode 403. Frog Jump
- 基于 JavaScript 语言的快速物联网开发架构
- Java Web学习总结(36)——JavaEE知识体系及项目开发过程的总结
- java过滤器
- Linux下Python2.7、pip的安装详解
- 编程题3-临考前5小时抱佛脚 //笑哭