相关疑难解决方法(0)

接受WebClient中的Cookie?

我刚开始尝试使用C#WebClient.我所拥有的是下面的代码,它从网站获取html代码并将其写入.txt文件.我唯一的问题是有些网站要求您在使用网站之前接受cookie.这导致的不是将真实的网站html代码写入.txt文件,而是编写cookie popup html代码.

码:

string downloadedString;
System.Net.WebClient client;

client = new System.Net.WebClient();

//"http://nl.wikipedia.org/wiki/Lijst_van_spelers_van_het_Nederlands_voetbalelftal"
downloadedString = client.DownloadString(textBox1.Text);

using (StreamWriter write = new StreamWriter("Data.txt"))
{
    write.Write(downloadedString);
}
Run Code Online (Sandbox Code Playgroud)

那么这个解决方案是什么?有人可以指引我走正确的道路吗?

html c# cookies webclient

16
推荐指数
3
解决办法
3万
查看次数

标签 统计

c# ×1

cookies ×1

html ×1

webclient ×1