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));
}

php正则获取网页标题、关键字、网页描述代码的更多相关文章

  1. Python2获取网页标题

    Python获取网页标题 使用Python2.x的urllib2和lxml,速度应该还快于BeautifulSoup4(话说回来,为什么大家都要用BS4呢?一个XPATH不就完了吗) 没有安装过的,用 ...

  2. html网页标题

    HTML代码 <html> <head> <!--<title>定义网页标题,显示在浏览器的标题--> <title>网页标题</ti ...

  3. (转)asp.net动态设置标题title 关键字keywords 描述descrtptions

    方法一 if (!IsPostBack){//Page title网页标题Page.Title = “我的网站标题”;//须将网页head标签设成服务器控件模式,即<head runat=&qu ...

  4. Vue动态修改网页标题

    业务需求,进入页面的时候,网页有个默认标题,加载的网页内容不同时,标题需要变更. 例:功能授权,功能授权(张三). Vue下有很多的方式去修改网页标题,这里总结下解决此问题的几种方案: 一.最笨方案 ...

  5. jquery无法修改网页标题,无法修改网页标题

    今天遇到一个问题,搜索时动态修改网页标题,用jquery的这段代码无效,无论FF还是IE $("title").html("new title"); 后来只好用 ...

  6. 获取WebView里的网页文本内容

    获取WebView里的网页文本内容,能够採用例如以下方法: public class ComJSInterface { public void loadHtmlContent(String conte ...

  7. JS获取屏幕,浏览器窗口大小,网页高度宽度(实现代码)_javascript技巧_

    JS获取屏幕,浏览器窗口大小,网页高度宽度(实现代码)_javascript技巧_--HTML5中文学习网 http://www.html5cn.com.cn/shili/javascripts/79 ...

  8. Chrome扩展程序——TabCopy:一键复制网页标题和网址

    Chrome扩展程序——TabCopy:一键复制网页标题和网址 - Erik_ly的博客 - CSDN博客 https://blog.csdn.net/u012318074/article/detai ...

  9. php 微信登录 公众号 获取用户信息 微信网页授权

    php 微信登录 公众号 获取用户信息 微信网页授权 先自己建立两个文件: index.php  和  getUserInfo.php index.php <?php //scope=snsap ...

随机推荐

  1. [转]Mysql海量数据存储和解决方案之一—分布式DB方案

    1)  分布式DB水平切分中用到的主要关键技术:分库,分表,M-S,集群,负载均衡 2) 需求分析:一个大型互联网应用每天几十亿的PV对DB造成了相当高的负载,对系统的稳定性的扩展性带来极大挑战. 3 ...

  2. sql server2008 字符串的替换

    DECLARE @TSql VARCHAR(MAX) SET @TSql =REPLACE(@TSql,'#PrimaryKey','0'); 1,@TSql将要替换的完整字符串 2,#Primary ...

  3. NET程序内存分析工具CLRProfiler的使用(性能测试)

    http://blog.csdn.net/wy3552128/article/details/8158938 大家都知道.net有一套自己的内存(垃圾)回收机制,除非有一些数据(方法)长期占有内存不随 ...

  4. 介绍 .Net工具Code Snippet 与 Sql Server2008工具SSMS Tools Pack

    不久前,某某在微软写了一个很酷的工具:Visual Stuido2008可视化代码片断工具,这个工具可以在http://www.codeplex.com/SnippetDesigner上免费下载,用它 ...

  5. vim python设置

    http://www.cnblogs.com/Leo-Forest/archive/2012/04/06/2435237.html http://linux-wiki.cn/wiki/zh-hans/ ...

  6. 【转】Nginx服务器的反向代理proxy_pass配置方法讲解

    [转]Nginx服务器的反向代理proxy_pass配置方法讲解 转自:http://www.jb51.net/article/78746.htm 就普通的反向代理来讲Nginx的配置还是比较简单的, ...

  7. VS2012 打开cs文件报未找到与约束错误

    一.问题发生 VS2012,更新补丁后的残忍--创建项目未找到与约束匹配的导出 创建项目时无法成功创建,而且提示:未找到与约束ontractNameMicrosoft.VisualStudio.Tex ...

  8. 打包文件 MANIFEST.MF 功能详解

    最近研究了如何在java工程打包,期间遇到的一些问题进行总结,如打包成test.jar 文件 Manifest-Version: 1.0 Main-Class: windows.VideoWindow ...

  9. C#集合及特殊字符

    集合里面 打印  出来时 要把 集合内的格式转化为其他格式! 壹. 集合 在.add之前 为空   数组  同样  添加元素之前 为  空(下一章超市购物例题具体体现) 1.System Collec ...

  10. supersr--去除tableViewHeader的粘性

    这段代码能去除tableViewHeader的粘性 const static NSInteger kSectionHeaderHeight = 30; - (void)scrollViewDidScr ...