コード例 #1
0
        public static void QueryIpAddress(string ip, string cookie)
        {
            HttpClient         client = new HttpClient();
            QQZengResponseData ipData = new QQZengResponseData()
            {
                ip = ip
            };                                                               // "59.66.134.35"

            string url = "https://www.qqzeng.com/ip/";
            HttpResponseMessage response = client.GetAsync(url).Result;
            HttpResponseHeaders heads    = response.Headers;

            foreach (var item in heads)
            {
                client.DefaultRequestHeaders.Add(item.Key, item.Value);
                string value = string.Join("", item.Value);
            }
            SetClientCookie(cookie, client);

            string      json = ipData.ConvertJson();
            HttpContent con  = new StringContent(json, System.Text.Encoding.UTF8);

            //  SetClientHeader(client,cookies);
            url = "https://www.qqzeng.com/ip/getIpInfo.php";
            string         text = client.PostAsync(url, con).Result.Content.ReadAsStringAsync().Result;
            QQZengResponse qqz  = text.ConvertObject <QQZengResponse>();
        }
コード例 #2
0
 public static void ExecuteWebHttp(string ip, string cookieStr)
 {
     QQZengResponseData ipData = new QQZengResponseData()
     {
         ip = ip
     };
     //CookieContainer cc = new CookieContainer();
     //foreach (string item in cookieStr.Split(';'))
     //{
     //    string[] cookie = item.Split('=');
     //    if (cookie.Length < 2) { return; }
     //    cc.Add(new Cookie(cookie[0], cookie[1]));
     //}
     string         ret = HttpClientExtend.HttpWebRequestPost("https://www.qqzeng.com/ip/getIpInfo.php", ipData.ConvertJson(), cookieStr);
     QQZengResponse qqz = ret.ConvertObject <QQZengResponse>();
 }