zoukankan      html  css  js  c++  java
  • c# 获取cook

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Text;
    
    
    namespace HQTX_BatchAddData
    {
        /// <summary>
        /// WinInet.dll wrapper
        /// </summary>
        internal static class CookieReader
        {
    
    
            private const int INTERNET_COOKIE_HTTPONLY = 0x00002000;
    
    
            [DllImport("wininet.dll", SetLastError = true)]
            private static extern bool InternetGetCookieEx(
                string url,
                string cookieName,
                StringBuilder cookieData,
                ref int size,
                int flags,
                IntPtr pReserved);
            public static string GetCookie(string url)
            {
                int size = 512;
                StringBuilder sb = new StringBuilder(size);
                if (!InternetGetCookieEx(url, null, sb, ref size, INTERNET_COOKIE_HTTPONLY, IntPtr.Zero))
                {
                    if (size < 0)
                    {
                        return null;
                    }
                    sb = new StringBuilder(size);
                    if (!InternetGetCookieEx(url, null, sb, ref size, INTERNET_COOKIE_HTTPONLY, IntPtr.Zero))
                    {
                        return null;
                    }
                }
                return sb.ToString();
            }
        }
    }
  • 相关阅读:
    Android安全研究经验谈
    论文相关笔记5
    论文相关笔记4
    论文相关笔记3
    论文相关笔记2
    论文相关笔记1
    朝鲜RedStar_OS_3.0安装图解
    Careerup上的简历模板
    冒泡、二分排序
    火狐插件
  • 原文地址:https://www.cnblogs.com/bfyx/p/8289796.html
Copyright © 2011-2022 走看看