[英]C# Spam in output, how can i fix it?
I want to make program in c# that will found value and show it in text box, but it's not a problem... When I tried to show this value, program spam in 1 text box, so it's impossible to read something. 我想用c#编写程序,该程序将找到值并在文本框中显示它,但这不是问题。当我试图显示此值时,请在1个文本框中编写垃圾邮件,因此无法读取内容。
private void button1_Click(object sender, System.EventArgs e)
{
using (var client = new WebClient())
{
string input = client.DownloadString("example.com");
textBox2.AppendText(input);
Regex regex = new Regex("[^<b>](.*)[^</b>]", RegexOptions.IgnoreCase);
Match match;
for (match = regex.Match(input); match.Success; match = match.NextMatch())
{
foreach (Group group in match.Groups)
{
textBox1.AppendText(string.Format("Value {0}", group));
}
}
}
}
1 Text box should show only the value 1文本框应仅显示值
2 Text box show html code from page 2文本框显示页面中的html代码
You can use CSQuery to parse your HTML: 您可以使用CSQuery解析HTML:
https://github.com/jamietre/CsQuery https://github.com/jamietre/CsQuery
CQ dom = "<div>Hello world! <b>I am feeling bold!</b> What about <b>you?</b></div>";
string bold = dom["b"].First().InnerText;
You can select elements like JQuery 您可以选择诸如JQuery之类的元素
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.