1 回答
TA贡献1830条经验 获得超3个赞
如果您使用的是最新版本的 simpleHTMLDom,则可以使用该remove()功能。这是基于您现有代码的示例代码
$html = file_get_html('https://homeshopping.pk/products/-Imported-Stretchable-Tights-For-Women--Pack-Of-3-.html');
foreach($html->find('div#ProductDescription_Tab') as $description)
{
$comments = $description->find('.hsn_comments', 0);
$comments->outertext = '';
//remove div with script
$description->find('div#flix-minisite',0)->remove();
$description->find('div#flix-inpage',0)->remove();
//will remove all <script> tags
foreach($description->find('script') as $s) $s->remove();
//wil remove all <style> tags
foreach($description->find('style') as $s) $s->remove();
echo $description->innertext ;
}
- 1 回答
- 0 关注
- 87 浏览
添加回答
举报