从HTML中提取标题标记 [英] Pulling Title Tag out of HTML
本文介绍了从HTML中提取标题标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一个简单的PHP代码可以拉出
网页的标题?我们需要在< title>< / titleand
之间插入单词。以下是他们的要求:
http://www.stumbleupon.com/submit?ur...+Article+Title
我们有网址但没有标题。
完整说明如下: http://www.stumbleupon.com/integrate.php
有什么想法吗?
解决方案
af ******** **@gmail.com 写道:
是否有一个简单的PHP代码可以拉出一个
的标题
网页出来了吗?我们需要在< title>< / titleand
之间插入单词。以下是他们的要求:
http://www.stumbleupon.com/submit?ur...+Article+Title
我们有网址但没有标题。
完整说明如下: http://www.stumbleupon.com/integrate.php
有什么想法吗?
使用正则表达式应该很容易。尝试类似:
text = file_get_contents(
url);
preg_match ( '' <标题>(*)< /标题> '',
Is there a simple piece of php code(s) that can pull the title of a
web page out? We need to pull the words in between <title></titleand
insert it into stumble upon. Here is what their requirements are:
http://www.stumbleupon.com/submit?ur...+Article+Title
We have the url but not the title.
The full instructions are here: http://www.stumbleupon.com/integrate.php
Any ideas?
解决方案
af**********@gmail.com wrote:Is there a simple piece of php code(s) that can pull the title of a
web page out? We need to pull the words in between <title></titleand
insert it into stumble upon. Here is what their requirements are:
http://www.stumbleupon.com/submit?ur...+Article+Title
We have the url but not the title.
The full instructions are here: http://www.stumbleupon.com/integrate.php
Any ideas?This should be easy with regular expressions. Try something like:
text = file_get_contents(
url);
preg_match(''<title>(.*)</title>'',
这篇关于从HTML中提取标题标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文