我怎麼能實現this solution here與Domcrawler?如何通過css選擇器(標籤,類和標識符)與Domcrawler刪除元素?
<?php
use Symfony\Component\DomCrawler\Crawler;
$crawler = new Crawler();
$content = file_get_contents('http://example.com/somepage.html');
$crawler->addHtmlContent($content, 'UTF-8');
$content = $crawler->filter('#main-content');
// Remove content by tag and by css selector.
?>
我已經將您的代碼作爲功能請求(http://bit.ly/1adIkGk)輸入到DomCrawler組件庫中。如果請求被接受,則稱爲「remove」的新方法將可用。因此,解決方案實現將變成幾乎只有一行代碼'$ crawler-> remove(array('script'));' –