我正在从远程页面获取 html 源代码,然后tbody
从中删除一些 s
来源在我的页面中回显这一切都很好,但我遇到的问题是我
想要将两个类名放在同一个h3
标签中,因为这是代码可以显示的唯一方式
在我的页面中正确
<?php
//Get the url
$url = "http://lsh.streamhunter.eu/static/section35.html";
$html = file_get_contents($url);
$doc = new DOMDocument(); // create DOMDocument
libxml_use_internal_errors(true);
$doc->loadHTML($html); // load HTML you can add $html
$elements = $doc->getElementsByTagName('tbody');
$toRemove = array();
// gather a list of tbodys to remove
foreach($elements as $el)
if((strpos($el->nodeValue, 'desktop') !== false) && !in_array($el->parentNode, $toRemove, true))
$toRemove[] = $el->parentNode;
foreach($elements as $el)
if((strpos($el->nodeValue, 'Recommended') !== false) && !in_array($el->parentNode, $toRemove, true))
$toRemove[] = $el->parentNode;
// remove them
foreach($toRemove as $tbody)
$tbody->parentNode->removeChild($tbody);
echo $doc->saveHTML(); // save new HTML
?>
我怎样才能使这两个类名eventtitle
和lshjpane-toggler lshtitle
在同一个 h3 标签中没有每个在单独的标签中
编辑:为了清楚地查看这段代码
<h3 class="lshjpane-toggler lshtitle eventtitle150909" onclick="getEvent(150909)"></h3><table cellpadding="0" cellspacing="0" border="0"><tr><td valign="middle" width="20px;" height="20px;" style="padding:0px 0px 0px 5px; background: url(/images/stories/kr.png) no-repeat scroll center;"></td>
<td valign="middle" style="padding:0px 0px 0px 5px;"><span class="lshstart_time">12:00</span></td>
<td valign="middle" style="padding:0px 0px 0px 5px;"><span class="lshevent">Daekyo Kangaroos Women - Incheon Red Angels Women</span></td>
</tr></table><h3 id="preloadevent150909" style="display:none" class="preload-lshjpane-toggler"></h3>
只有在删除</h3>
之前它才会正确显示<table
如何从从远程页面检索到的代码中删除此标记