我要做一个彩票网站,我需要自动开奖 所以我想要做一个windows服务去抓取其他网站的开奖号码 因为他是10分钟跳一次,开一次奖的 我想问一下 我应该怎么去用时间控制windows服务让他每10分钟 抓开一次奖? 希望知道的朋友给出比较详细的回答 O(∩_∩)O谢谢!!
解决方案 »
- decimal(8, 0)
- JQ 类似日历控件(直接选择年、月份的)
- Asp.net大内存使用,内存回收导致无响应的问题
- js问题2个日期相差的年数
- 谁那有ajax的小例子(页面上就有一两个TextBox,DropdownList,不能为空,然后把他们的值封装到一个类里面,在传到另一个页面)
- 调用ocx时出现c:\inetpub\wwwroot\WebApplication3\WebForm1.aspx.cs(23): 不可访问“PDFViewer.PDFViewClass.PDFViewClass()”,因为它
- http://www.qschina.com/我们公司开发的电子商务网站,若发现有bug,每bug100分。
- 请教如何给checkbox添加点击事件,求正解!
- 环境异常获取系统日期格式问题
- ASPNETFORUMS已经安装成功,但是为何不能搜索中文啊?
- GridView+sql多次查询问题
- 不同用户之间如何共享数据?
HttpWebrequest抓取网页内容,再用正则根据html格式获取数据
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)";
System.Net.WebResponse response = request.GetResponse();
System.IO.Stream resStream = response.GetResponseStream();
System.IO.StreamReader sr = new System.IO.StreamReader(resStream, encoding);
string html = sr.ReadToEnd();
resStream.Close();
恩 谢谢 抓取网页数据 我知道
System.Timers.Timer timer = new System.Timers.Timer(1000);
timer.Elapsed += new System.Timers.ElapsedEventHandler(this.timer_Elapsed);
timer_Elapsed这是个时间 这样是不是就控制了 timer_Elapsed每间隔1秒中就要执行一次?
timer.Interval = _TimerInterval;//给计时器轮循一个时间间隔
this.timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
timer.Start();void timer_Elapsed(object sender, ElapsedEventArgs e)
{
timer.Stop(); //先停止计时器计时,免得打乱操作
try
{
YourProcess();
}
catch (Exception ex)
{
throw ex;
}
finally
{
timer.Start();
}
}
timer.Elapsed += new System.Timers.ElapsedEventHandler(this.timer_Elapsed);
timer_Elapsed这是个时间 这样是不是就控制了 timer_Elapsed每间隔1秒中就要执行一次?timer.Interval才是设置timer的时间间隔的
timer.Elapsed += new System.Timers.ElapsedEventHandler(this.timer_Elapsed);
这是建事件委托的,意思是timer到点触发timer_Elapsed这个函数