VB.NET 根据IP地址返回IP所在地的方法

VB.NET 根据IP地址返回IP所在地的方法,第1张

概述#Region "读取http:" ''' <summary> ''' 读取http://www.yodao.com接口IP地址 ''' </summary> Public Shared Function GetstringIpAddress(strIP As String) As String 'strIP为IP Dim sURL
#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

设计蜂巢IP地址查询接口:http://www.hujuntao.com/API/ip/ip.PHP 腾讯IP地址查询接口:http://fw.qq.com/ipaddress 新浪IP地址查询接口:http://int.dpool.sina.com.cn/iplookup/iplookup.PHP?format=Js 搜狐IP地址查询接口:http://pv.sohu.com/cityJson 谷歌IP地址查询接口:http://j.maxmind.com/app/geoip.Js 有道IP地址查询接口:http://www.youdao.com/smartresult-xml/search.s 1616 IP地址查询接口:http://w.1616.net/chaxun/iptolocal.PHP 126 http://ip.ws.126.net/ipquery hao123 http://app.hao123.com/ipquery/getcity.PHP?rtype=2 设计蜂巢接口调用方法

API请求地址 : http://www.hujuntao.com/API/ip/ip.PHP?参数

参数说明:

IP : IP地址 可选 format : 输出格式 Json 可选 默认为Js

JsON调用示例:
请求地址:http://www.hujuntao.com/API/ip/ip.PHP?callback=jquery17107324279078748077_1327024991339&format=Json&_=1327024991363

{
“ip”: “117.89.35.58″,
“province”: “\u6c5f\u82cf”,
“city”: “\u5357\u4eac”
}

腾讯接口调用方法
      <script src="http://fw.qq.com/ipaddress"></script>    type"text/JavaScript">    //反回格式如下:    //var IPData = new Array("117.89.35.98","","江苏省","南京市");    console.log(IPData[0]+','+23]) //117.89.35.98,江苏省,南京市    </script>  

该方法已经不可用,访问http://fw.qq.com/ipaddre显示“The page you are looking for is temporarily unavailable.
Please try again later.”。腾讯对Referer做了判断,虽然可以通过PHP伪造Referer,但是实际测试中获得的是服务器的IP地址而不是客户端的IP地址。我们一起鄙视一下腾讯。╭∩╮(︶︿︶)╭∩╮

新浪接口调用方法
"http://int.dpool.sina.com.cn/iplookup/iplookup.PHP?format=Js"//format参数设置返回格式 Js/Json    //ip 要查询IP 可选    //反回格式如下:    //var remote_ip_info = {"ret":1,"start":"117.89.35.0","end":"117.89.35.255","country":"\u4e2d\u56fd","province":"\u6c5f\u82cf","city":"\u5357\u4eac","district":"\u767d\u4e0b","isp":"\u7535\u4fe1","type":"","desc":""};    (remote_ip_info["country"+"province""省"+"city""市")//中国,南京市    </script>  
搜狐接口调用方法
"http://pv.sohu.com/cityJson?IE=utf-8"//默认为GBK可通过IE参数设置编码    returnCitySN"cip""cname"]) 据说是谷歌的,不知道是不是真的。

"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"?>
<smartresult>
<product type="ip">
<ip>123.233.157.9</ip>
<location>山东省济南市 网通</location>
</product>
</smartresult>

或者

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’:'局域网 对方和您在同一内部网’},”);
总结

以上是内存溢出为你收集整理的VB.NET 根据IP地址返回IP所在地的方法全部内容,希望文章能够帮你解决VB.NET 根据IP地址返回IP所在地的方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/langs/1284364.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存