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>(); }
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); } }
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>(); }