百度ip定位城市接口调用
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定位城市接口调用的更多相关文章
- 根据IP定位城市
根据IP定位城市:http://www.sucaihuo.com/js/35.html 示例:http://www.sucaihuo.com/jquery/0/35/demo/
- c#百度IP定位API使用方法
c#百度IP定位API使用方法 1.先建立一个收集信息的实体类 IPModel.cs: using System; using System.Collections.Generic; using Sy ...
- 百度地图API的IP定位城市和浏览器定位(转)
百度地图API提供了Geolocation 和 LocalCity两个服务类. 这俩API可以分别供用户在JavaScript中进行定位和城市确认. 1 本质上,Geolocation这个类是使用了支 ...
- ip转城市接口,ip转省份接口,ip转城市PHP方法
新浪接口(速度快) $url = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip='.$ip; $arr ...
- 百度地图api之----根据用户ip定位城市
LocalCity 这个类是利用用户IP地址去百度数据库里查询得到IP所在的城市,用法如下: var objCity = new BMap.LocalCity(); objCity.get(funct ...
- IP定位,天气接口
首先获取IP ////获得本地真实IP function get_onlineip() { $ip_json = @file_get_contents("http://ip.taobao.c ...
- 淘宝ip地址库接口会导致TTFB时间变长,网站打开速度变慢
前一段时间闲来无事发现别人的网站上有显示当前用户城市的功能,就自己也整了一个 这是淘宝ip地址库调用方法 然后问题就出现了,网站打开速度慢的要死 用F12发现是TTFB太慢,然后百度了,发现了问题的原 ...
- web端ip定位
1/新浪定位 <script src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js">&l ...
- C#调用百度高精度IP定位API通过IP获取地址
API首页:http://lbsyun.baidu.com/index.php?title=webapi/high-acc-ip 1.申请百度账号,创建应用,获取密钥(AK) http://lbsyu ...
随机推荐
- LeetCode 547 朋友圈
题目: 班上有 N 名学生.其中有些人是朋友,有些则不是.他们的友谊具有是传递性.如果已知 A 是 B 的朋友,B 是 C 的朋友,那么我们可以认为 A 也是 C 的朋友.所谓的朋友圈,是指所有朋友的 ...
- 机器学习sklearn
sklearn相关模块导入 from sklearn.feature_extraction import DictVectorizer from sklearn.feature_extraction. ...
- c++ 指针与const的三种组合
三种形式 const int a=1; int b=2: 1 const int * ptr1=&a; 2 int * const ptr2 = b; 3 const int * const ...
- spring对bean的高级装配之基于@Conditional条件化装配
上篇介绍了如何基于profile来条件化创建bean,spring会根据profile的激活状态来进行创建;这篇介绍如何基于spring4.0引入的@Conditional和Condition接口来更 ...
- vs code 本地请求json
首先下载扩展live server 重新加载后 右下方工具栏会多出一个go live 点击go live,会默认启动chome,地址 http://127.0.0.1:5500 js脚本: $.aj ...
- kafka学习笔记整理01
Apache Kafka 消息中间件->流式数据处理平台 特点: 高可靠性(分布式.分区.复制和容错).高吞吐量.持久化 消息模式:1)队列式(或点对点):在点对点消息系统中,消息被保存在队列中 ...
- Activity简说
Activity 四个状态 running 运行:前台显示,当前焦点 paused 暂停:上面被其他activity覆盖,有一部分可见 stopped 停止:被其他activity完全覆盖,不可见 d ...
- Graphics Class
System.Drawing 封装一个 GDI+ 绘图图面. 此类不能被继承. https://docs.microsoft.com/zh-cn/dotnet/api/system.drawing.g ...
- 写入一个html文件时的编码要求
with open("ip.html",'w',encoding='utf-8') as fp: fp.write(response)
- python day33 ,socketserver多线程传输,ftp作业
一.一个服务端连多个客户端的方法 1.服务端 import socketserver class MyServer(socketserver.BaseRequestHandler): def hand ...