使用httpwebrequest或webclient下载包含SWF内容的html源代码

时间:2016-07-14 05:51:59

标签: c#

在下载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);
         }

0 个答案:

没有答案