webclient doesn't download the web page completely

旧时模样 提交于 2019-12-13 04:58:48

问题


Have code for download page:

 System.Net.WebClient client = new System.Net.WebClient();
 client.Headers.Add("user-agent", "Mozilla/20.0.1");
 byte[] feedBytes;
 string url;
 url = @"http://www.marathonbet.co.uk/en/betting/Football";
 string fullPage = string.Empty;
 try
 {
      feedBytes = client.DownloadData(url);
 }
 catch (System.Net.WebException)
 {
      return;
 }
string fullPage = Encoding.UTF8.GetString(feedBytes);

As result 'fullpage' contains only part of page. In the browser loading of the page happens gradually. How to download full page?


回答1:


Try this

public static string GetHTMLDocument(string url)
        {
            var result = "";
            using (var wc = new WebClient())
            {
                result = wc.DownloadString(url);
            }
            return result;
        }


来源:https://stackoverflow.com/questions/16926445/webclient-doesnt-download-the-web-page-completely

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!