我想用C#程序获取源代码等html内容。但是,我需要在页面上等待30秒,然后获取网站内容。我尝试使用下面的代码,但我无法在页面上等待。我该如何解决这个问题?
_url = System.Web.HttpUtility.HtmlDecode(_url);
string result = "";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(_url);
using (var httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse())
{
using (Stream stream = httpWebResponse.GetResponseStream())
{
string charSet = httpWebResponse.CharacterSet;
Encoding encoding = Encoding.GetEncoding(_encode);
var reader = new StreamReader(stream, encoding);
result = reader.ReadToEnd().Replace("\r\n", "").Trim();
//Console.WriteLine (result);
//Console.ReadLine();
}
}