[英]how to remove all script tags in a html content with CsQuery
我正在使用CsQuery庫進行爬網。 代碼是這樣的。
var dom = CQ.CreateDocument(htmlContent);
resultText= dom[cssSelector].Text();
我不需要resultText
腳本標簽,例如這部分<script> somethings </script>
我嘗試了這個dom[cssSelector].Not("script").Text();
。 但是沒有用。
如何刪除所有腳本值?
該庫三年未更新,因此有可能不再起作用。
查看給定的文檔,您可以嘗試使用:
CQ script = dom["script"];
script.remove();
這將刪除所有腳本標簽
解決了。 此代碼刪除所有腳本。
dom = dom["body script"].Remove();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.