如何获取网站 [英] how to fetch website

查看:83
本文介绍了如何获取网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个先生,使这些页面一个接一个.
我想设置只在一个窗口中显示一个再见的时间
使用计时器控件一页一页地显示网页,间隔为10秒
设置时间

I use this sir and I get these pages one below another.
I want to set the time for display one bye one only in one window
display webpages in one page one by one with 10 sec gap using timer control
to set time

WebRequest req = WebRequest.Create("http://www.google.com");
WebRequest req2 = WebRequest.Create("http://www.princemahesh.com");
WebResponse resp1 = req2.GetResponse();
Stream s1 = resp1.GetResponseStream();
StreamReader sr1 = new StreamReader(s1, Encoding.ASCII);
string doc1 = sr1.ReadToEnd();
Label2.Text = doc1;

WebResponse resp = req.GetResponse();

Stream s = resp.GetResponseStream();
StreamReader sr = new StreamReader(s,Encoding.ASCII);
string doc = sr.ReadToEnd();

Label1.Text = doc;

推荐答案

使用asnyc方法,例如 camtasia之类的东西 [^ ]记录输出和操作.
Look into use asnyc methods like WebRequest.BeginGetResponse[^] this way when the first BeginGetResponse() completes start a timer so that 10seconds later another BeginGetResponse() begins for the second address.

I do have to say that the need to show one site then another 10seconds later through code makes no sense, if this is for a demo use something like camtasia[^] to record the output and what to do.


也许只需使用Response.WriteResponse.Flush即可.

像这样的东西:
Maybe it would simply work by using Response.Write and Response.Flush.

Something like:
Response.Write(doc1);
Response.Flush;
Sleep(10000);
Response.Write(doc2);



祝你好运!



Good luck!


这篇关于如何获取网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆