(html中会有其他iframe,所以我试图通过类名调用它们)
我试过了:
$html = "<iframe width='100%' height='600' class='report' id='CReport' src=' http://www.example.com' ></iframe>";
$doc = new DOMDocument();
@$doc->loadHTML($html);
$tags = $doc->getElementsByClassName('report');
$url = $tags->getAttribute('src');
echo $url;
答案 0 :(得分:0)
尝试使用以下代码:
<?php $tags = $doc->getElementById('CReport'); ?>