1 回答

TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超3個(gè)贊
如果您使用的是最新版本的 simpleHTMLDom,則可以使用該remove()功能。這是基于您現(xiàn)有代碼的示例代碼
$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 關(guān)注
- 139 瀏覽
添加回答
舉報(bào)