如何使用php获取网站的标题和描述?
可能的重复:
帮助获取元标题和描述
我花了一整天的时间。网上搜了一下。在 satckoverflow 上也看到了一些类似的问题。但我得到的却是失望。
我想获得一些 php 代码,通过它我可以输出标题和一些 4-5 行的内容,用于使用 php 的任何网站的描述。
Possible Duplicate:
Help getting meta title and description
I've spend a full day on it. Searched on the net. Saw some similar questions on satckoverflow also. but all I got disappointment.
I want to get some php code by which I can output the title and some 4-5 lines for the description of any website using php.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需更改网址即可:)
Just change the url:)
解析 HTML 的方法有很多种。首先,您需要内容本身:
假设允许 file_get_contents 访问 uri。
例如,您可以使用正则表达式:
但最好使用 DOM 解析器。 http://php.net/manual/en/book.xml.php ,但如果目标内容不是有效的 xml,这可能会出现问题。
There are many ways to parse a HTML. First, you want the content itself:
That assumes file_get_contents allowed to access uri.
For example, you might utilize a regex:
But it would be better to use a DOM parser. http://php.net/manual/en/book.xml.php, though that may be problem if the target content is not valid xml.