我想做个数据采集器,把中国体育彩票开奖的信息取出来。
不懂怎么动手,请详细指点一下。网站数据采集彩票
不懂怎么动手,请详细指点一下。网站数据采集彩票
解决方案 »
- 1 摄像头如果不是免驱动的,那么用WIN API是不是也调不同摄像头? 2 视频会议类似的开发视频用什么方法传输会好一些?
- inset语句执行成功..数据库中却没有数据!急!!!
- .net中的SetImageAttributesOutputChannel可以设置输出通道为CMYK中的一种,那么有没有可以直接输出RGB通道中一种的函数呢?
- 图片拖动实现不了拉
- 一个关于HttpWebRequest处理Cookie的问题
- winform连access数据库,加密app字符串
- 请教 访问SqlServer2005 Report Services问题
- Flash Scoket 发布成HTML没法连接
- 请问:如何隐藏全局鼠标,不只在当前进程
- 正则匹配1/3-1/2-1-1½
- c#怎样创建一个动态的string数组
- 求助一个问题,
{
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();
}
}
}
}
前几天看到的一个案例.
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("utf-8")))
{
string html = sr.ReadToEnd();
string pattern=@"(?i)<tr((?!.*?bgcolor)[^>]*?)>\s*?<td[^>]*?>\s*?<font>([^>]*?)</font>\s*?</td>\s*?<td[^>]*?>([^<>]*?)</td>\s*?<td[^>]*?>\s*?<table[^>]*?>[\s\S]*?(<td[^>]*?>((?<Num>\d+)|\s*?)</td>)*?\s*?</tr>\s*?[\s\S]*?</table>";
var result = Regex.Matches(html, pattern).OfType<Match>().Select(a => new {
玩法=a.Groups[2].Value,
期号=a.Groups[3].Value,
开奖号=string.Join(" ",a.Groups["Num"].Captures.OfType<Capture>().Select(b=>b.Value))
});
/*
+ [0] { 玩法 = "大乐透", 期号 = "13082 ", 开奖号 = "03 09 25 26 33 03 12" } <Anonymous Type>
+ [1] { 玩法 = "排列3", 期号 = "13191 ", 开奖号 = "4 7 3" } <Anonymous Type>
+ [2] { 玩法 = "排列5", 期号 = "13191 ", 开奖号 = "4 7 3 4 4" } <Anonymous Type>
+ [3] { 玩法 = "22选5", 期号 = "13172 ", 开奖号 = "08 09 14 15 19" } <Anonymous Type>
+ [4] { 玩法 = "7星彩", 期号 = "13082 ", 开奖号 = "6 0 8 0 1 4 8" } <Anonymous Type> */ }
}
主要还是html分析 可以使用 htmlagilitypack参考 http://www.cnblogs.com/wangchuang/archive/2013/03/11/2953638.html