Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用httpwebrequest或webclient下载包含SWF内容的html源_C# - Fatal编程技术网

C# 使用httpwebrequest或webclient下载包含SWF内容的html源

C# 使用httpwebrequest或webclient下载包含SWF内容的html源,c#,C#,在下载这个网站的html源代码时,我只得到了脚本数据,而不是整个html内容, 我尝试使用webclient和httpwebrequest HttpWebRequest请求=(HttpWebRequest)WebRequest.Create(“http://”+网站) 或 可能重复的作品对我来说,你的代码在哪里,以便我们可以看到是否有问题?将其添加到您的问题中。我不想在DocumentCompleted eventWebClient上运行该选项。DownloadFile没有仅包含1个参数的重载:

在下载这个网站的html源代码时,我只得到了脚本数据,而不是整个html内容, 我尝试使用webclient和httpwebrequest

HttpWebRequest请求=(HttpWebRequest)WebRequest.Create(“http://”+网站)


可能重复的作品对我来说,你的代码在哪里,以便我们可以看到是否有问题?将其添加到您的问题中。我不想在DocumentCompleted eventWebClient上运行该选项。DownloadFile没有仅包含1个参数的重载:此外,如果需要html内容,请使用DownloadString。
        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();
          }
        using (WebClient client = new WebClient()) 
        {
         client.DownloadFile(website);
         }