其他分享
首页 > 其他分享> > WebBrowser获取完整的Cookie

WebBrowser获取完整的Cookie

作者:互联网

WebBrowser 获取Cookie
1.string cookieStr = WebBrowser.Document.Cookie;//获取不全
2.
[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool InternetGetCookieEx(string pchURL, string pchCookieName, StringBuilder pchCookieData, ref int pcchCookieData, int dwFlags, object lpReserved);

private static string GetCookieString(string url)
{
//确定cookie的大小
int datasize = 512;
StringBuilder cookieData = new StringBuilder(datasize);

if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x00002000, null))
{
if (datasize < 0)
return null;

//分配足够大的stringbuilder以容纳cookie
cookieData = new StringBuilder(datasize);
if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x00002000, null))
return null;
}
return cookieData.ToString();
}
View Code

 

标签:datasize,string,InternetGetCookieEx,StringBuilder,获取,Cookie,cookieData,WebBrowse
来源: https://www.cnblogs.com/qixiaolan/p/15571854.html