Esempio n. 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>();
        }
Esempio n. 2
0
        void LoadCompate()
        {
            string text = webBrowser.DocumentText;

            rtbHtml.Text = text;
            HtmlElementCollection eles = webBrowser.Document.GetElementsByTagName("tr");

            foreach (HtmlElement item in eles)
            {
                string html = item.OuterHtml;
                if (html.Contains("ip_info"))
                {
                    rtbHtmlData.Text += "\r\n" + html;
                }
            }
            QQZengResponseData qqzeng = rtbHtmlData.Text.HtmlConvertIpData();
            HtmlElement        ipe    = webBrowser.Document.GetElementById("obviousIp");

            if (ipe != null)
            {
                string iphtml = ipe.OuterHtml;
                qqzeng.ip = iphtml.Split(new string[] { ">" }, StringSplitOptions.None)[1].Split(new string[] { "<" }, StringSplitOptions.None)[0];
            }
            string json = qqzeng.ConvertJson();

            rtbTip.Text = json;
            if (!string.IsNullOrEmpty(qqzeng.ip) && !waitSave.Any(p => p.ip == qqzeng.ip))
            {
                waitSave.Add(qqzeng);
            }
        }
Esempio n. 3
0
        public static QQZengResponseData HtmlConvertIpData(this string html)
        {
            /*
             *
             * <tr class="ip_info_a">
             * <td class="ip-td">亚洲</td>
             * <td class="ip-td">中国</td>
             * <td class="ip-td">北京</td>
             * <td class="ip-td">北京</td>
             * <td class="ip-td"></td>
             * <td class="ip-td">鹏博士</td>
             * </tr>
             * <tr class="ip_info_b">
             * <td class="ip-td">110100</td>
             * <td class="ip-td">China</td>
             * <td class="ip-td">CN</td>
             * <td class="ip-td">116.405285</td>
             * <td class="ip-td">39.904989</td>
             * <td class="ip-td">20170607</td>
             * </tr>
             */
            RegexHtmlConvertIpData(html);
            string[] ele = html.Split(new string[] { "class=\"ip-td\"" }, StringSplitOptions.None).
                           Where(s =>
            {    //<tr class="ip_info_a"><td
                if (!s.Contains("</") || !s.Contains(">"))
                {
                    return(false);
                }
                return(true);
            }).
                           Select(s =>
            {
                s = s.LSubstringExt("</");
                s = s.RSubstringExt(">");
                return(s);
            }).ToArray();
            if (ele.Length < 12)
            {
                return(new QQZengResponseData());
            }
            QQZengResponseData qqzeng = new QQZengResponseData();

            qqzeng.continent = ele[0];
            qqzeng.country   = ele[1];
            qqzeng.province  = ele[2];
            qqzeng.city      = ele[3];
            qqzeng.district  = ele[4];
            qqzeng.isp       = ele[5];
            qqzeng.areacode  = ele[6];
            qqzeng.en        = ele[7];
            qqzeng.cc        = ele[8];
            qqzeng.lng       = ele[9];
            qqzeng.lat       = ele[10];
            qqzeng.version   = ele[11];
            return(qqzeng);
        }
Esempio n. 4
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>();
 }