请问,如何时时抓取彩票开奖数据,我的程序用的是Access数据库,
比如:下面网页的数据,10分钟更新一次,如何抓取
http://www.500wan.com/static/public/ssc/txt/opencode/29.txt或者是:
http://jk.trade.500wan.com/ssc/
右边的开奖数据
比如:下面网页的数据,10分钟更新一次,如何抓取
http://www.500wan.com/static/public/ssc/txt/opencode/29.txt或者是:
http://jk.trade.500wan.com/ssc/
右边的开奖数据
参考代码
public static string HttpGetHtmlSource(string url, string encodingName, HttpMethod httpMethod, Dictionary<string, string> postData)
{
System.Text.Encoding encoding= System.Text.Encoding.GetEncoding(encodingName);
System.Net.WebResponse response = GetWebReponse(url, httpMethod, postData, encoding);
System.IO.Stream stream = response.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(stream, encoding);
string html = reader.ReadToEnd();
stream.Close();
reader.Close();
response.Close();
return html;
}
public static string HttpGetHtmlSource(string url, string encodingName, HttpMethod httpMethod, Dictionary<string, string> postData)
{
System.Text.Encoding encoding= System.Text.Encoding.GetEncoding(encodingName);
System.Net.WebResponse response = GetWebReponse(url, httpMethod, postData, encoding);
System.IO.Stream stream = response.GetResponseStream();
System.IO.StreamReader reader = new System.IO.StreamReader(stream, encoding);
string html = reader.ReadToEnd();
stream.Close();
reader.Close();
response.Close();
return html;
}
public static string GetHttpPostData(System.Text.Encoding encoding, Dictionary<string, string> postData)
{
if (postData == null || postData.Count < 1)
{
return null;
}
StringBuilder sbData = new StringBuilder();
foreach (var item in postData)
{
sbData.AppendFormat("{0}={1}&", HttpUtility.UrlEncode(item.Key, encoding), HttpUtility.UrlEncode(item.Value, encoding));
}
if (sbData.Length > 0)
{
sbData.Length = sbData.Length - 1;
}
return sbData.ToString();
}
第二部分析html代码
要么直接字符串截取,要么正则。第三部分变化
反正别人有变化,你也及时修改代码,
可以做个job,定时把抓下来的对比,有变化,显示一个默认的,然后通知自己。