在html
标记之一中,该标记具有:
<ul class="l1nk">
<li class="dir online">
<a target="_blank" rel="nofollow" href="https://sample.com/embed/2882015?ref=7Qc" title="ONLINE">
online
</a>
</li>
<li class="kftfhd">
<a rel="nofollow" target="_blank" href="https://sample.com/2882015-11-HQ_1080.mp4?ref=7Qc" title="Full HD">Full HD</a>
</li>
<li class="kft1080">
<a rel="nofollow" target="_blank" href="https://sample.com/2882015-11-1080.mp4?ref=7Qc" title="1080p">1080p</a>
</li>
<li class="kft720">
<a rel="nofollow" target="_blank" href="https://sample.com/2882015-11-720.mp4?ref=7Qc" title="720p">720p</a>
</li>
<li class="kft480">
<a rel="nofollow" target="_blank" href="https://sample.com/2882015-11-480.mp4?ref=7Qc" title="480p">480p</a>
</li>
</ul>
我试图获得链接href
与自我文本,如:
https://sample.com/embed/2882015?ref=7Qc
带有ONLINE
我的代码,它不是不正确的是:
$dom = new Dom;
$dom->loadFromUrl("https://sample.org/film/");
$l1nk = $dom->find('.l1nk')->getChildren();
foreach ($l1nk as $data) {
echo $data->getAttribute('a');
}
1条答案
按热度按时间wf82jlnq1#
或者,您可以使用
getElementsByTagName()
: