100求解郁闷了很久的问题-提取网页内容

asuyr 2005-08-17 09:17:14
需要编写一个程序,当打开一个网页时,需要复制网页上的内容到文本文件.
不是网页的HTML语言.各位大哥,大姐,帮帮忙忙呀.
...全文
136 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
TechEye 2005-08-17
  • 打赏
  • 举报
回复
string strHtml = "<html><title>Welcome to Intel.Com</Title>....";
Regex reg = new Regex(@"<[^>]*?>", RegexOptions.IgnoreCase);

string strText = reg.Replace(strHtml, "");

Console.WriteLine(strText);
fanruinet 2005-08-17
  • 打赏
  • 举报
回复
将html标签都删掉
content = "......";
Regex htmlRegex = new Regex(@"<[^>]*?>", RegexOptions.IgnoreCase | RegexOptions.Compiled);
content = htmlRegex.Replace(content, "");
fanruinet 2005-08-17
  • 打赏
  • 举报
回复

content = "......";
Regex htmlRegex = new Regex(@"<[^>]*?>", RegexOptions.IgnoreCase | RegexOptions.Compiled);
content = htmlRegex.Replace(content, "");
将HTML标签都删掉
shrinerain 2005-08-17
  • 打赏
  • 举报
回复
string oStr="xxx";//获取的网页代码
Console.WriteLine(Regex.Replace(oStr,@"</?[^>]*>",""));//打印去掉html标记后的内容

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧