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 關注
- 148 瀏覽
添加回答
舉報