使用simple_html_dom.php解析img标记

时间:2013-06-13 11:49:34

标签: php

任何人都可以帮我解析使用simplehtmldom解析器的img src

<noscript><img alt="Tiergarten, Berlin" src="http://cdn1.gbot.me/photos/dg/mK/1284593632/Tiergarten__Berlin-Tiergarten-3000000027259-500x375.jpg" title="Tiergarten, Berlin" /></noscript>

1 个答案:

答案 0 :(得分:1)

点击此链接http://simplehtmldom.sourceforge.net/

<?php
include 'simple_html_dom.php';

$html = str_get_html('<noscript><img alt="Tiergarten, Berlin" src="http://cdn1.gbot.me/photos/dg/mK/1284593632/Tiergarten__Berlin-Tiergarten-3000000027259-500x375.jpg" title="Tiergarten, Berlin" /></noscript>');

foreach($html->find('img') as $element) {
  echo $element->src . '<br>';
}