VB.NET 根据IP地址返回IP所在地的方法
#Region "读取http:" ''' <summary> ''' 读取http://www.yodao.com接口IP地址 ''' </summary> Public Shared Function GetstringIpAddress(strIP As String) As String 'strIP为IP Dim sURL As String = "http://www.youdao.com/smartresult-xml/search.s?type=ip&q=" & strIP & "" 'youdao的URL Dim stringIpAddress As String = "" Using read As XmlReader = XmlReader.Create(sURL) '获取youdao返回的xml格式文件内容 While read.Read() Select Case read.NodeType Case XmlNodeType.Text '取xml格式文件当中的文本内容 If String.Format("{0}",read.Value).ToString().Trim() <> strIP Then 'youdao返回的xml格式文件内容一个是IP,另一个是IP地址,如果不是IP那么就是IP地址 '赋值 stringIpAddress = String.Format("{0}",read.Value).ToString().Trim() End If Exit Select 'other End Select End While End Using Return stringIpAddress End Function '返回的xml数据格式 ' <?xml version="1.0" encoding="gbk" ?> '- <smartresult> '- <product type="ip"> ' <ip>60.223.233.226</ip> ' <location>山西省朔州市 网通</location> ' </product> ' </smartresult> #End Region
设计蜂巢接口调用方法API请求地址 : http://www.hujuntao.com/api/ip/ip.php?参数 参数说明:
JSON调用示例: { 腾讯接口调用方法
该方法已经不可用,访问http://fw.qq.com/ipaddre显示“The page you are looking for is temporarily unavailable. 新浪接口调用方法"http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"//format参数设置返回格式 js/json
搜狐接口调用方法"http://pv.sohu.com/cityjson?ie=utf-8"//默认为GBK可通过ie参数设置编码
据说是谷歌的,不知道是不是真的。 "http://j.maxmind.com/app/geoip.js"geoip_country_name()+geoip_region_namegeoip_city())//China,Jiangsu,Nanjing 调用接口示例:http://www.youdao.com/smartresult-xml/search.s?type=ip&q=123.233.157.9 返回XML数据 <?xml version="1.0" encoding="gbk"?> 或者 http://www.youdao.com/smartresult-xml/search.s?jsFlag=true&keyfrom=163.com&event=fYodaoCallBack&type=ip&q=192.168.1.1 返回JSON数据 fYodaoCallBack(1,{‘product’:'ip’,'ip’:’192.168.1.1′,’location’:'局域网 对方和您在同一内部网’},”); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |