------ Solution ---------------------------------------- ---- nationwide distribution ip assignment with phone numbers
is about the same, are based on the number of regions have different segments
You need to match the look ip given is based on that area . .
------ Solution ---------------------------------------- ----
this is java , you can reference .
http://showtime520.iteye.com/blog/340548
----- - Solution --------------------------------------------
<script type=text/javascript src=http://fw.qq.com/ipaddress></script>
<script type=text/javascript>
document.write(IPData.join(' '));
</script>
------ Solution -------------------------------------- ------
I have this interface can get into the program code also !
If you need to be able to find me !
------ Solution ---------------------------------------- ----
package Test;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
public class IPtest {
private static EndpointReference targetRPR =
new EndpointReference ("http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?wsdl"); / / web service address
public void getResult () throws Exception
{
ServiceClient sender = new ServiceClient ();
sender.setOptions (buildOptions ());
OMElement result = sender.sendReceive (buildParam ());
System.out.println (result.toString ());
}
private OMElement buildParam () {
OMFactory fac = OMAbstractFactory.getOMFactory ();
OMNamespace omNs = fac.createOMNamespace ("http://WebXml.com.cn/", " " ) ;
OMElement data = fac.createOMElement ("getCountryCityByIp", omNs); / / method name
OMElement inner = fac.createOMElement ("theIpAddress", omNs); ;/ / parameter names
inner.setText ("58.195.128.56"); ; ; / / input parameters into
data.addChild (inner);
return data;
}
private Options buildOptions () {
Options options = new Options ();
options.setSoapVersionURI (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
options.setAction ("http://WebXml.com.cn/getCountryCityByIp");
options.setTo (targetRPR);
options.setTransportInProtocol (Constants.TRANSPORT_HTTP);
return options;
}
/ **
* @ param args
* /
public static void main (String [] args) {
IPtest t = new IPtest ();
try {
t.getResult ();
} catch (Exception e) {
/ / TODO Auto-generated catch block
e.printStackTrace ();
}
}
}
------ For reference only ---------------------------------- -----
------ For reference only ---------------------------------- -----
which I also know that the key is to not know how to use java code
------ For reference only ---------------- -----------------------
we also use this IP library .
------ For reference only -------------------------------------- -
except pure ip address database , what a way to die ?
------ For reference only -------------------------------------- -
seek expert !
------ For reference only -------------------------------------- -
unrealistic ip, show only the city, how to write it?
------ For reference only -------------------------------------- -
<script type=text/javascript src=http://fw.qq.com/ipaddress></script>
<script type=text/javascript>
document.write(IPData[2] + IPData[3]);
</script>
------ For reference only ----------------------------------- ----
wait master. . . . . .
------ For reference only -------------------------------------- -
Xie 11th floor , I mainly want the background code !
------ For reference only -------------------------------------- -
private static void getData(String querySQL) throws Exception{
URL url = new URL("http://api.liqwei.com/location/");
// 打开连接,此处只是创建一个实例,并没有真正的连接
HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
httpCon.setDoOutput(true);//打开写入属性
httpCon.setRequestMethod("GET");//设置提交方法
String params = "ip=" +rs.getString("ip_address");
// 此处调用getOutputStream会隐含的进行connect操作,所以不用在上面显示调用connect()
httpCon.getOutputStream().write(params.getBytes());
httpCon.getOutputStream().flush();
httpCon.getOutputStream().close();
//如果inputStream读操作在outputStream的写操作之前,会抛java.net.ProtocolException
//将内存缓冲区中封装好的完整的HTTP请求电文发送到服务端。
InputStream inputStream = httpCon.getInputStream();
InputStreamReader inputReader = new InputStreamReader(inputStream,"gbk");
BufferedReader bufferReader = new BufferedReader(inputReader);
String inputLine = null;
StringBuffer sb = new StringBuffer();
while ((inputLine = bufferReader.readLine()) != null) {
sb.append(inputLine);
}
bufferReader.close();
inputReader.close();
inputStream.close();
System.out.println(sb.toString());
}
Before you run this method , go to the next http://api.liqwei.com/location/, that there are many interfaces for you to use , you find the IP 's , you know , how to get city. Sb is printed above the query to the data.
------ For reference only -------------------------------------- -
thank you very much !
------ For reference only -------------------------------------- -
direct use interface calls , now Taobao , Sina interface calls are accurate.
For example, you can go to the next http://ip.taobao.com/service/getIpInfo.php?ip=211.138.125.150 their official website api
没有评论:
发表评论