[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]    //API设定Cookie
        static extern int InternetSetCookieEx(string lpszURL, string lpszCookieName, string lpszCookieData, int dwFlags, IntPtr dwReserved);
        [DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]    //API获取Cookie
        static extern bool InternetGetCookieEx(string pchURL, string pchCookieName, StringBuilder pchCookieData, ref System.UInt32 pcchCookieData, int dwFlags, IntPtr lpReserved);
        private string GetCookieString(string url)    //url通过API获取完整Cookie
        {
            uint datasize = 256;
            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();
        }

 

相关文章:

  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2022-01-25
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
  • 2021-11-23
  • 2021-06-12
  • 2021-07-28
  • 2022-12-23
相关资源
相似解决方案