问题
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