delphi获取Cookie源码.rar

时间:2018-03-05 02:01:49
【文件属性】:

文件名称:delphi获取Cookie源码.rar

文件大小:896B

文件格式:RAR

更新时间:2018-03-05 02:01:49

delphi源码

获取Cookie [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; } } } 复制代码 //本事件是当每次加载完成当前页面后才会执行的 private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { //e.Url是当前加载的页面, if (e.Url.ToString().Contains("http://www.3yeah.com")) { //执行操作1 } else if (e.Url.ToString().Contains("http://baidu.com")) { //执行操作2 } } 复制代码 private void webBrowser1_NewWindow(object sender, CancelEventArgs e) { if (cbwindownew.Checked) { string url = ((System.Windows.Forms.WebBrowser)sender).StatusText; webBrowser1.Navigate(url); e.Cancel = true; } } 复制代码


【文件预览】:
获取Cookie.txt

网友评论

  • 看看 不知道用得吗