从链接获取标题,PHP Simple HTML DOM Parser [英] Get title from link, PHP Simple HTML DOM Parser
本文介绍了从链接获取标题,PHP Simple HTML DOM Parser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从链接中获取标题 - 我已经确定了这个标题,只是在同一个链接中检索标题的最后一个。
I'm trying to get the title from a link - which I already have identified, it is just the last bit with retrieving the title from the same link.
要找到正确的链接,我使用这段代码:
To find the right link I use this code:
$html->find('a[href=http://mylink.se']');
但我也想要这个链接的标题。如何做到这一点?
But I also want the title from this link. How would I do that?
推荐答案
假设您使用PHP Simple HTML DOM解析器,这在您的问题中不清楚,你可以做
Assuming you're using PHP Simple HTML DOM parser, which is not clear in your question, you could do
$link = $html->find('a[href=http://mylink.se]', 0); //As the OP pointed out in comments, you need to select the first element
$title = $link->title
http://simplehtmldom.sourceforge.net/manual.htm
这篇关于从链接获取标题,PHP Simple HTML DOM Parser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文