第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

帶有簡單 html dom 解析器的垃圾 Javascript 和 Css 代碼

帶有簡單 html dom 解析器的垃圾 Javascript 和 Css 代碼

慕容森 2023-10-30 20:41:58
我正在使用簡單的 html dom 解析器來解析 php 的鏈接。下面是我正在使用的 url 和 php 代碼。網(wǎng)址:https://homeshopping.pk/products/-Imported-Stretchable-Tights-For-Women--Pack-Of-3-.htmlPHP 腳本:$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 = '';      print $description->outertext ;}問題是,運(yùn)行腳本后,我得到了我想要的前端,但查看頁面源代碼會(huì)顯示大量 javascript 和 css 垃圾代碼??梢詥幔课也荒苤猾@取 html 標(biāo)簽而不需要任何額外的 css 或 javascript 代碼嗎?下面是我的 php 腳本運(yùn)行腳本后查看頁面源的圖像。https://i.stack.imgur.com/78X6z.jpg
查看完整描述

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 ;


}


查看完整回答
反對(duì) 回復(fù) 2023-10-30
  • 1 回答
  • 0 關(guān)注
  • 139 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)