简体   繁体   English

C#:块特定的HTML代码

[英]C#: Block Specific HTML Code

Let's say that I want to block the specific HTML code 假设我要阻止特定的HTML代码

<script async annoyingcode.js> AnnoyingCodeHere </script>

in a website in WebBrowserControl1 . WebBrowserControl1中的网站中。 I tried using WebClient1.DownloadFile("website.html", @"C:\\BlockerWork") , File.ReadAllText(@"C:\\BlockerWork") , String.Replace , then WebBrowserControl1.DocumentStream , but it simply takes too long to run and requires downloading all the time. 我尝试使用WebClient1.DownloadFile("website.html", @"C:\\BlockerWork")File.ReadAllText(@"C:\\BlockerWork")String.Replace ,然后使用WebBrowserControl1.DocumentStream ,但是它花费的时间太长运行,并需要一直下载。 Is there an easier way in C#? C#中有更简单的方法吗?

您可以使用WebClient1.DownloadString("website.html")跳过文件操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM