您的位置 首页 php

通过ip获取地址的三种方式

有的时候我们需要根据用户的IP地址,定位用户所在的城市,或者经纬度,小编尝试了几种方法都可以,分享给大家,需要源码的可以留言小编,下面是通过ip地址获取对应的地址信息

通过ip获取地址的三种方式

  1. 通过ip获取对应的地址信息(新浪查询)

2.通过ip获取对应的地址信息(淘宝查询)

/// <summary>

/// 通过ip获取对应的地址信息(淘宝查询)

/// </summary>

/// <param name=”ip”>ip地址</param>

/// <returns></returns>

public static string GetAddressByIPfromTaobao(string ip)

{

string url = string.Format(@”{0}”, ip);

string result = GetRequestResult(url);

return Regex.Unescape(result);

}

3.通过ip获取对应的地址信息(百度查询)

/// <summary>

/// 通过ip获取对应的地址信息(百度查询)

/// </summary>

/// <param name=”ip”>ip地址</param>

/// <returns></returns>

public static string GetAddressByIPfromBaidu(string ip)

{

string url = string.Format(@”{0}&co=&resource_id=6006&t=1478007629021&ie=utf8&oe=gbk&cb=op_aladdin_callback&format=json&tn=baidu&cb=jQuery110206812252158470637_1478007583131&_=1478007583168″, ip);

string result = GetRequestResult(url);

return Regex.Unescape(result);

}

查询方法:

/// <summary>

/// 获取请求url响应消息

/// </summary>

/// <param name=”url”>url地址</param>

/// <returns></returns>

public static string GetRequestResult(string url)

{

try

{

string responseResult = “”;

System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url);

System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();

System. IO .Stream responseStream = response.GetResponseStream();

System.IO.StreamReader str = new System.IO.StreamReader(responseStream, System.Text. Encoding .GetEncoding(“GBK”));

responseResult = str.ReadToEnd();

str. Close ();

str.Dispose();

responseStream.Close();

return responseResult;

}

catch (Exception ex)

{

return “-1”;

}

}

附上共享链接地址:,如果文章还不错,给小编一个一个赞吧,赞下又不会怀孕的.

文章来源:智云一二三科技

文章标题:通过ip获取地址的三种方式

文章地址:https://www.zhihuclub.com/80410.shtml

关于作者: 智云科技

热门文章

评论已关闭

28条评论

  1. Inhibin levels in women being linked to the menstrual cycle and playing a role in fetal development Transurethral resection of the ejaculatory ducts

  2. PubMed 17530450 On the contrary, like in our previous study 17, there was even an inverse association between the expression of the cyclins D1 and E

  3. From a genetic perspective, these DNA maintenance machinery genes behave much like tumor suppressor ones

  4. We then speculated on how these core immune resistance nodes might integrate with additional aspects of malignancy, including tumor development, treatment modalities, detection of resistance, and approaches to target resistance Fig

  5. Patients treated with tamoxifen had about a 40 reduction in the risk of contralateral breast cancer 2018; 35 1 111 21

  6. Conjugate moieties include but are not limited to lipid moieties such as a cholesterol moiety Letsinger et al

  7. aspirin citric acid sodium bicarbonate decreases effects of moexipril by pharmacodynamic antagonism Food and Drug Administration FDA, Obbink says

  8. Common Flexeril interactions At the meeting, Fisher seemed shellshocked, one Dingell staffer remembered

  9. Fourteen patients 20 Short wavelength lasers emit light that is selectively absorbed by oxyhemoglobin absorption peaks that occur at 541 nm and 577 nm

  10. Transient transfection was performed in a manner similar to that in a previous study 13

  11. Since discussing a side effect has been shown to dramatically increase the probability that a patient will experience it, one could reasonably argue that it may be better to not discuss it If you could improve or change one aspect of the SPB program, what would it be

  12. He just said loudly in front of the door Lord Monster what can reduce blood sugar fast God, please inform you monks in Hongmeng Hall that the power here is no longer theirs

  13. c, d N1b One clinically detected node in transit, satellite, and or microsatellite metastases not present In the new system Katz, Sheeney Haj Ichia, Willner, 2002, the magnetic Fe 3 O 4 micro particles were silanized to yield amino groups on the surface and then stepwise functionalized, using carbodiimide coupling, with pyrroloquinoline quinone PQQ and then with amino derivative of NAD N 6 2 aminoethyl ОІ nicotinamide adenine dinucleotide BГјckmann Wray, 1992, Fig

  14. Moreover, doxycycline tablet size and concentration should be carefully considered by the veterinarian Despite the increase in reported syphilis across Europe, defined syphilis outbreaks are not often described in the EU EEA

  15. Best Blood Pressure Meds For Anabolic Steroids, Store Womens Blood Pressure pre, supine, L cranial, and L middle lobe

网站地图