WebRequest wc = HttpWebRequest.Create("http://www.cznd.gov.cn/node/jrgxq_qnyw/2013-7-5/137512575342148320.html"); wc.ContentType = "application/x-www-form-urlencoded;charset=gb2312"; using (WebResponse wq = wc.GetResponse()) { using (Stream s = wq.GetResponseStream()) { using (StreamReader sr = new StreamReader(s, Encoding.GetEncoding("gb2312"))) { string html = sr.ReadToEnd(); Match m = Regex.Match(html, @"(?i)<td[^>]*?class=(['""]?)NewsContent\1[^>]*?>\s*?<p[^>]*?>\s*?([\s\S]*?)</p>"); string result = m.Groups[2].Value; Console.Write(result); Console.ReadLine(); } } } 前几天看到的代码收藏了。
参见:
http://www.cnblogs.com/xiaozhi_5638/p/3167794.html
文章最后几段
没办法啊,公司要求采集几个网站的数据,不是很会啊,就想找点书籍教程看看,能推荐几篇文章吗?
Httpwebrequest跨权限获得源码的
没办法啊,公司要求采集几个网站的数据,不是很会啊,就想找点书籍教程看看,能推荐几篇文章吗?
Httpwebrequest跨权限获得源码的什么叫做“跨权限”。
最近几个月一直在做工业监控,以太网、USB、串口等等的采集终于有些眉目了。
没办法啊,公司要求采集几个网站的数据,不是很会啊,就想找点书籍教程看看,能推荐几篇文章吗?
Httpwebrequest跨权限获得源码的什么叫做“跨权限”。就是在没有权限获取资源的时候,如何获取到资源.其实就是利用点非正常的手段.
wc.ContentType = "application/x-www-form-urlencoded;charset=gb2312";
using (WebResponse wq = wc.GetResponse())
{
using (Stream s = wq.GetResponseStream())
{
using (StreamReader sr = new StreamReader(s, Encoding.GetEncoding("gb2312")))
{
string html = sr.ReadToEnd();
Match m = Regex.Match(html, @"(?i)<td[^>]*?class=(['""]?)NewsContent\1[^>]*?>\s*?<p[^>]*?>\s*?([\s\S]*?)</p>");
string result = m.Groups[2].Value;
Console.Write(result);
Console.ReadLine();
}
}
}
前几天看到的代码收藏了。