首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何获取网页meta标签的内容

如何获取网页meta标签的内容
EN

Stack Overflow用户
提问于 2013-05-08 02:39:02
回答 1查看 290关注 0票数 0

我正在尝试读取一个安全网页的元标签的内容。但是发现它很难,因为属性不是一般的,如姓名,作者等。如果他们是任何可能的方式,请告诉。

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-08 03:09:42

你在php.net上看过这些帖子了吗?

代码语言:javascript
复制
<meta name="author" content="name">
<meta name="keywords" content="php documentation">
<meta name="DESCRIPTION" content="a php manual">
<meta name="geo.position" content="49.33;-86.59">
</head> <!-- parsing stops here -->

使用下面编写的php代码读取这些meta标签

代码语言:javascript
复制
<?php
// Assuming the above tags are at www.example.com
$tags = get_meta_tags('http://www.example.com/');

// Notice how the keys are all lowercase now, and
// how . was replaced by _ in the key.
echo $tags['author'];       // name
echo $tags['keywords'];     // php documentation
echo $tags['description'];  // a php manual
echo $tags['geo_position']; // 49.33;-86.59
?>

这些代码取自http://php.net/manual/en/function.get-meta-tags.php

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16426232

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档