http://lbsyun.baidu.com/index.php?title=webapi/ip-api

require 'rubygems'
require 'json'
print ARGV
print "fist is :",ARGV[0]
logfile="#{ARGV[0]}_log" filex = File.open(logfile, "w+") File.foreach(ARGV[0]) do |line|
line = line.gsub("\n", "")
result = `curl "http://api.map.baidu.com/location/ip?ak=xxxx&ip=#{line}"`
puts "http://api.map.baidu.com/location/ip?ak=xxxx&ip=#{line}"
puts result
begin
filex << "#{line}:#{JSON.parse(result)["content"]["address_detail"]["province"] } #{JSON.parse(result)["content"]["address_detail"]["city"] }"
rescue
filex << "#{line}: #{''}"
end
filex << "\n"
break
end

将ak替换成自己的ak, 参数为全是ip 每行一个的文件;

普通开发者每天2000次调用,升级个人开发者可达到3w ;

个人认证:http://lbsyun.baidu.com/apiconsole/auth#/creat/person

百度ip定位城市接口调用的更多相关文章

  1. 根据IP定位城市

    根据IP定位城市:http://www.sucaihuo.com/js/35.html 示例:http://www.sucaihuo.com/jquery/0/35/demo/

  2. c#百度IP定位API使用方法

    c#百度IP定位API使用方法 1.先建立一个收集信息的实体类 IPModel.cs: using System; using System.Collections.Generic; using Sy ...

  3. 百度地图API的IP定位城市和浏览器定位(转)

    百度地图API提供了Geolocation 和 LocalCity两个服务类. 这俩API可以分别供用户在JavaScript中进行定位和城市确认. 1 本质上,Geolocation这个类是使用了支 ...

  4. ip转城市接口,ip转省份接口,ip转城市PHP方法

    新浪接口(速度快) $url = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip='.$ip; $arr ...

  5. 百度地图api之----根据用户ip定位城市

    LocalCity 这个类是利用用户IP地址去百度数据库里查询得到IP所在的城市,用法如下: var objCity = new BMap.LocalCity(); objCity.get(funct ...

  6. IP定位,天气接口

    首先获取IP ////获得本地真实IP function get_onlineip() { $ip_json = @file_get_contents("http://ip.taobao.c ...

  7. 淘宝ip地址库接口会导致TTFB时间变长,网站打开速度变慢

    前一段时间闲来无事发现别人的网站上有显示当前用户城市的功能,就自己也整了一个 这是淘宝ip地址库调用方法 然后问题就出现了,网站打开速度慢的要死 用F12发现是TTFB太慢,然后百度了,发现了问题的原 ...

  8. web端ip定位

    1/新浪定位 <script src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js">&l ...

  9. C#调用百度高精度IP定位API通过IP获取地址

    API首页:http://lbsyun.baidu.com/index.php?title=webapi/high-acc-ip 1.申请百度账号,创建应用,获取密钥(AK) http://lbsyu ...

随机推荐

  1. android spf 存储 集合(实体等)

    package com.example.sharedpreferencelist; import java.io.ByteArrayInputStream;import java.io.ByteArr ...

  2. Python的基础语法

    一,编码 默认情况下,Python 3 源码文件以 UTF-8 编码,所有字符串都是 unicode 字符串. 当然你也可以为源码文件指定不同的编码: 1 # -*- coding: cp-1252 ...

  3. Delphi 对ini文件的操作

    界面如图: 代码如下: unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Vari ...

  4. Thread类源码解析

    源码版本:jdk8 其中的部分论证和示例代码:Java_Concurrency 类声明: Thread本身实现了Runnable接口 Runnable:任务,<java编程思想>中表示该命 ...

  5. plt库

  6. 【Linux】【Kernel】一个简单的内核模块例子

    1.本地主机的参数 zhangjun@zhangjun-virtual-machine:~$ uname -a Linux zhangjun-virtual-machine 4.4.0-31-gene ...

  7. java 第三周作业

    1.P132分析: long before = System.currentTimeMillis(); //返回当前的计算机时间,时间的表达格式为当前计算机时间和GMT时间(格林威治时间)1970年1 ...

  8. 配置xml报错:URI is not registered ( Setting | Project Settings | Schemas and DTDs )

    报红提示:URI is not registered ( Setting | Project Settings | Schemas and DTDs ) 解决方法:打开Schemas and DTDs ...

  9. MySQL在高内存、IO利用率上的几个优化点

    以下优化都是基于CentOS系统下的一些MySQL优化整理,有不全或有争议的地方望继续补充完善. 一.mysql层面优化 1. innodb_flush_log_at_trx_commit 设置为2设 ...

  10. wpf binging(五) 数据的转换与验证

    1.数据的验证,有时候需要验证同步的数据是否正常 需要派生一个类 ValidationRule 再把这个类指定给binging 进行验证 在这里如果验证不通过 textbox就会变成红色并且发出警告数 ...