我想在C#中执行以下操作:
我之前尝试过此操作
WebClient
类下载网站的字符串
WebClient client = new WebClient();
string reply = client.DownloadString(url);
client.DownloadFile(gesamter_String, @"C:\neu\localfile.html");
Console.WriteLine(reply);
HTTPClient
类下载网站的字符串
string url = hyperlink;
HttpClient client = new HttpClient();
using (HttpResponseMessage response = client.GetAsync(url).Result)
{
using (HttpContent content = response.Content)
{
string result =content.ReadAsStringAsync().Result;
Console.WriteLine(result);
}
}
但是下载或显示的源代码很小,并且不包含特定的链接。
但是我的链接有效。我已使用以下链接打开了前台链接:System.Diagnostics.Process.Start(url);
。这个前台打开的站点包含完整的源代码。
非常感谢。