[C#] 纯文本查看 复制代码 [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool InternetGetCookieEx(string pchUrl, string pchCookieName, StringBuilder pchCookieData, ref System.UInt32 pcchCookieData, int dwFlags, IntPtr lpReserved);
private static string GetCookieString(string url)
{
uint datasize = 1024;
StringBuilder cookieData = new StringBuilder((int)datasize);
if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x2000, IntPtr.Zero))
{
if (datasize < 0)
return null;
cookieData = new StringBuilder((int)datasize);
if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x00002000, IntPtr.Zero))
return null;
}
return cookieData.ToString();
}
private void webBrowser1_DocumentCompleted_1(object sender, WebBrowserDocumentCompletedEventArgs e)
{
richTextBox1.Text = string.Empty;
if (cbcookie.Checked)
{
if (checkBox1.Checked)
{
richTextBox1.Text = GetCookieString(textBox1.Text.Trim());
}
else
{
richTextBox1.Text = webBrowser1.Document.Cookie;
}
}
}
通过这里的方法,只能取到一部分cookie,还有其他部分的cookie可能被淘宝设置成httpOnly了,
现在就是不能获取到完整的Cookie,有其他方法吗?
群主帮忙看看有没有其他解决方案? |