1, the way to use the interface:
This approach is relatively stable, and the data provided is relatively stable, providing a lot of interface, you can refer to
Http://www.hujuntao.com/api/the-ip-address-api-and-call-the-interface-method.html
Do not explain, only to explain the interface Sina provides:
Sina interface Address: http://int.dpool.sina.com.cn/iplookup/iplookup.php
There are two parameters: Format and IP
1 IP: The default is native IP when the IP value is not passed in, or the specific IP address can be specified;
2 format: The data returned to the client is formatted in JS and JSON format:
A, return JS format:
eg:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=115.29.28.108
Returned result: var Remote_ip_info = {"ret": 1, "Start": "115.28.0.0", "End": "115.29.255.255", "Country": "\u4e2d\u56fd", "Province ":" \u5317\u4eac "," City ":" \u5317\u4eac "," District ":" "," ISP ":" \u7535\u4fe1 "," type ":" \u673a\u623f "," desc ":" \u4e2d \u56fd\u4e07\u7f51\u673a\u623f\u7535\u4fe1 "};
Return the result to a JS variable, the variable value is JSON format, you can convert Unicode characters to Chinese:
var remote_ip_info = {"ret": 1, "Start": "115.28.0.0", "End": "115.29.255.255", "Country": "China", "province": "Beijing", "City": " Beijing, "District": "", "ISP": "Telecommunications", "type": "Room", "desc": "China million Network Room Telecommunications"};
B, return JSON format:
eg:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=115.29.28.108
return Result:
{"ret": 1, "Start": "115.28.0.0", "End": "115.29.255.255", "Country": "\u4e2d\u56fd", "Province": "\u5317\u4eac", "City" : "\u5317\u4eac", "District": "", "ISP": "\u7535\u4fe1", "type": "\u673a\u623f", "desc": "\u4e2d\u56fd\u4e07\u7f51\ U673a\u623f\u7535\u4fe1 "}
The returned result is directly a JSON-formatted string that can be converted to Chinese by itself:
{"ret": 1, "Start": "115.28.0.0", "End": "115.29.255.255", "Country": "China", "province": "Beijing", "City": "Beijing", "District": "", "ISP": "Telecom", "type": "Room", "desc": "China million Network Room Telecommunications"}
code example:
<div> <asp:gridview id= "Gvdetail" runat= "Server" cellpadding= "4" forecolor= "#333333" gridlines= "None"
Width= "100%" autogeneratecolumns= "false" > <alternatingrowstyle backcolor= "White"/> <editrowstyle backcolor= "#2461BF"/> <footerstyle backcolor= "#507CD1" font-bold= "True" ForeColor = "White"/>
Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/script/