乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      新浪網易淘寶等IP地區(qū)信息查詢開放API接口調用方法

       開啟美好每一天 2014-01-15

      通過IP地址獲取對應的地區(qū)信息通常有兩種方法:
      1)自己寫程序,解析IP對應的地區(qū)信息,需要數據庫。
      2)根據第三方提供的API查詢獲取地區(qū)信息。

      第一種方法,參見文本《通過純真IP數據庫獲取IP地址對應的地區(qū)信息》,這種方法的維護代價較高,而且對自己的服務器有一定的壓力。

      隨著技術的開放,第三方已經逐漸免費開放相應的API。經過測試,目前網易和新浪提供的較為穩(wěn)定易用。

      1)新浪IP地址查詢API接口

      新浪的IP地址查詢接口:

      http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=IP地址

      測試用例:

      http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=115.156.238.114

      返回以下信息:

      1. var remote_ip_info = {"ret":1,"start":"115.156.128.0","end":"115.156.255.255","country":"\u4e2d\u56fd","province":"\u6e56\u5317","city":"\u6b66\u6c49","district":"","isp":"\u6559\u80b2\u7f51","type":"\u5b66\u6821","desc":"\u534e\u4e2d\u79d1\u6280\u5927\u5b66\u4e1c\u6821\u533a"};  

      文字經過utf-8編碼,分別對應不同的信息。
      可以通過javascript跨域直接調用,如(使用jquery):

      1. $.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip='+ip, function(_result){  
      2. if (remote_ip_info.ret == '1'){   
      3. alert('IP 詳細信息:', 'IP:'+ip+'<BR>國家:'+remote_ip_info.country+'<BR>省份:'+remote_ip_info.province+'<BR>城市:'+remote_ip_info.city+'<BR>區(qū):'+remote_ip_info.district+'<BR>ISP:'+remote_ip_info.isp+'<BR>類型:'+remote_ip_info.type+'<BR>其他:'+remote_ip_info.desc);   
      4. } else {   
      5. alert('錯誤', '沒有找到匹配的 IP 地址信息!');   
      6. }  

      2)網易有道IP地址API接口

      查詢IP地址:

      http://www.youdao.com/smartresult-xml/search.s?type=ip&q=IP地址

      舉例:

      http://www.youdao.com/smartresult-xml/search.s?type=ip&q=115.156.238.114

      返回xml文本信息:

      1. <?xml version="1.0" encoding="gbk"?>  
      2. <smartresult>  
      3. <product type="ip">  
      4. <ip>115.156.238.114</ip>  
      5. <location>湖北省武漢市 教育網</location>  
      6. </product>  
      7. </smartresult>  

      3)淘寶IP地址庫API接口

      1. 請求接口(GET):

      http://ip.taobao.com/service/getIpInfo.php?ip=[ip地址字串]

      2. 響應信息:

      (json格式的)國家 、?。ㄗ灾螀^(qū)或直轄市)、市(縣)、運營商

      3. 返回數據格式:

      {"code":0,"data":{"ip":"210.75.225.254","country":"\u4e2d\u56fd","area":"\u534e\u5317",
      "region":"\u5317\u4eac\u5e02","city":"\u5317\u4eac\u5e02","county":"","isp":"\u7535\u4fe1",
      "country_id":"86","area_id":"100000","region_id":"110000","city_id":"110000",
      "county_id":"-1","isp_id":"100017"}}
      其中code的值的含義為,0:成功,1:失敗。

      訪問限制:為了保障服務正常運行,每個用戶的訪問頻率需小于10qps。
      詳細請參看API主頁:http://ip.taobao.com/

      4)太平洋IP地址庫API接口

      http://whois.pconline.com.cn/?ip=[ip地址字符串]

      調用方法非常豐富,提供多種JS嵌入調用。

      另外,還有Google,搜狐,騰訊等均提供相應接口,請參看相關資料,這里不再贅述。

        本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯系方式、誘導購買等信息,謹防詐騙。如發(fā)現有害或侵權內容,請點擊一鍵舉報。
        轉藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多