- 积分
- 10954
- 好友
- 记录
- 主题
- 帖子
- 听众
- 收听
|
//导入应用API的DLL,使用wininet.dll预留的方法:InternetSetCookie
[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool InternetSetCookie(string lpszUrlName, string lbszCookieName, string lpszCookieData);
List<Cookie> cookielist =...//获取到的Cookies
for (int i = 0; i < cookielist.Count; i++)
{
//逐一设置Cookie,参数依次为:URL,Cookie名称,Cookie值
if (InternetSetCookie("URL", cookielist[i].Name, cookielist[i].Value))
{}
else
{ MessageBox.Show("失败");
}
}
//Cookies设置完毕后,使用WebBrowser直接访问URL即可。这时,WebBrowser会携带写入的Cookie访问指定URL
this.webBrowser1.Navigate("URL");
|
|