在下载http://www.orientalcuisines.in/此网站的html源代码时,结果我只得到脚本数据而不是整个html内容, 我尝试使用webclient以及httpwebrequest。
HttpWebRequest request =(HttpWebRequest)WebRequest.Create(“http://”+ website);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = null;
if (response.CharacterSet == null)
{
readStream = new StreamReader(receiveStream);
}
else
{
readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
}
string data = readStream.ReadToEnd();
response.Close();
readStream.Close();
}
OR
using (WebClient client = new WebClient())
{
client.DownloadFile(website);
}