如何获取网页元标记的内容 [英] How to get content of the meta tag of a webpage

查看:157
本文介绍了如何获取网页元标记的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图读取安全网页的元标记的内容。但发现它很难,因为这些属性不是一般的名称,作者等。如果他们有任何可能的请告诉。

I am trying to read the content of a meta tag of a secure web page. But finding it difficult as the properties are not the general one like name, author etc. If their is any way possible please tell.

预先感谢。

推荐答案

你是否在php.net中阅读过这些文章?

did you gone through these post in php.net ?

<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代码阅读这些元标记

read these meta tags using php code writte below

<?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

这篇关于如何获取网页元标记的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆