读取一条网址内的内容

Gomes 2012-01-13 02:54:13
在textbox里输入https://forum.csdn.net/BList/DotNET/,然后就显示该页面的HTML代码出来。并且查询到<span id="test">fdafds</span>标签内的内容fdafds.
...全文
52 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Gomes 2012-01-13
  • 打赏
  • 举报
回复
HTML代码已经可以获取到,但是string字符的长度不够。该怎么办。
Gomes 2012-01-13
  • 打赏
  • 举报
回复
string patten="id=\"test\">(?<value>)</span>";
Regex r = new Regex(patten, RegexOptions.IgnoreCase);
MatchCollection collections = r.Matches(html);
这个如何输入得到标签里的value?
雨师88 2012-01-13
  • 打赏
  • 举报
回复
HttpWebRequest webRequest2 = (HttpWebRequest)WebRequest.Create(new Uri(url));
webRequest2.CookieContainer = webcookies["1"];
HttpWebResponse rsps = (HttpWebResponse)webRequest2.GetResponse();
StreamReader sr = new StreamReader(rsps.GetResponseStream(), Encoding.UTF8);
html = sr.ReadToEnd();
sr.Close();
string patten="id=\"test\">(?<value>)</span>";
Regex r = new Regex(patten, RegexOptions.IgnoreCase);
MatchCollection collections = r.Matches(html);

110,535

社区成员

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

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

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