通过ip查询对方位置
我们这里使用的是baidumap的高精度IP定位API的接口,具体说明可以参考baidu提供的文档
使用前需要申请一个AK密钥类似于Kgcx......................xxl8w的样式
http://api.map.baidu.com/highacciploc/v1?qcip=220.xxx.xx.113&qterm=pc&ak=Kgcx......................xxl8w&coord=bd09ll&extensions=1
这是我的访问的URL,其中参数可以参考文档给出的定义
下图是访问到的网页
这里我主要写一个脚本,对抓到的html进行格式化
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 12 12:40:24 2016 @author: Administrator
"""
import requests
import json URL = 'http://api.map.baidu.com/highacciploc/v1?qcip=110.xxxx.31.6&qterm=pc&ak=Kgcx0pNF6.....................xl8w&coord=bd09ll&extensions=1' def get_html(url):
headers = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1581.2 Safari/537.36'}
text = requests.get(url,headers=headers).text
return text def formated_html(text):
jo = json.loads(text) #或者直接用eval函数将text转成dict
business = jo['content']['business']
for k,v in jo['content']['address_component'].items():
print k,':', v
print 'formatted_address',':',jo['content']['formatted_address']
print 'business',':',jo['content']['business']
print 'location',':',jo['content']['location'] if __name__ == '__main__':
text = get_html(URL)
formated_html(text)
下面是格式化后的结果:
但是官方给出了注意事项:成功率:综合定位成功率 65% ,精度:90% 误差 80m 以内;95% 误差 350m
通过ip查询对方位置的更多相关文章
- 二维码生成与windows系统IP查询功能
一个木函是一款强大的手机软件,里面囊括了很多小功能,每一个都基本可以堪称小程序.那么,这些小功能具体是怎么实现的呢?让我们来一起来探讨二维码生成.IP查询这两个功能吧! 一.二维码生成 首先,我们来看 ...
- js的定位实现和ip查询
sina的api var GetLocationFromSina = function (successFunc, errorFunc) { $.getScript('http://int.dpool ...
- 纯净得只剩下字的访问IP查询API
纯净得只剩下字的访问IP查询API 实用资源 / 2018-02-26 / 3 条评论 看到一个好玩的,就随手收藏一下,本API作用:获取用户真实IP,而获取用户IP常见的坑有两个,开发支付的时候也需 ...
- 运用百度开放平台接口根据ip地址获取位置
使用百度开放平台接口根据ip地址获取位置 今天无意间发现在百度开放平台接口,就把一段代码拿了下来,有需要的可以试试看:http://opendata.baidu.com/api.php?query=5 ...
- IP查询接口1
新浪的:http://counter.sina.com.cn/ip?ip=IP地址返回Js数据,感觉不是很精确,可以把问号后面的去掉,直接返回本机对应的IP所在地http://www.yodao.co ...
- IP查询接口
腾讯的: http://fw.qq.com/ipaddress直接返回本机的IP地址对应的地区新浪的:http://counter.sina.com.cn/ip?ip=IP地址返回Js数据,感觉不是很 ...
- PHP获取访客IP、地区位置信息、浏览器、来源页面
不多说了,每个方法都注释了,可以直接用: <?php //这个类似用来获取访客信息的 //方便统计 class visitorInfo { //获取访客ip public function ge ...
- IP查询系统的异步回调案例
package com.lxj.demo; import java.io.BufferedReader; import java.io.IOException; import java.io.Inpu ...
- windows中修改IP映射的位置
windows中修改IP映射的位置 置顶 2018年08月05日 14:42:44 wangxiaolong0 阅读数:1473 在安装linux之后,发现windows不能通过映射来访问linu ...
随机推荐
- [LeetCode] Burst Balloons 打气球游戏
Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by ...
- [LeetCode] Rising Temperature 上升温度
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to ...
- 单例模式中用volatile和synchronized来满足双重检查锁机制
背景:我们在实现单例模式的时候往往会忽略掉多线程的情况,就是写的代码在单线程的情况下是没问题的,但是一碰到多个线程的时候,由于代码没写好,就会引发很多问题,而且这些问题都是很隐蔽和很难排查的. 例子1 ...
- PHP中多站点的设置
当初配置多站点的问题,整了几个小时没整好,第二天一看才发现是单词拼错了(无奈..),所以能复制的一定复制!!! 1,首先进行Apache的配置(先复制一份进行备份,以免丢失). 进入Apache文件下 ...
- spring 拦截器
1.mvc.xml <!-- 自定义拦截链配置 --> <mvc:interceptors> <mvc:interceptor> <mvc:mapping p ...
- Linux 基础操作
根据关键字查找文件信息: cat <文件名> | grep <关键字>查询文件信息 显示100行: tail -100f easyhome.all.log |grep &quo ...
- chrome 更新flash插件
下载下面的插件并安装 https://fpdownload.macromedia.com/pub/labs/flashruntimes/flashplayer/install_flash_player ...
- echarts-在现实标题中显示百分比
如图:需要在标题显示所占百分比 使用方式:途中标记部分 series : [{ name: '类型', type: 'pie', radius : '55%', center: ['50%', '60 ...
- xv6课本翻译之——附录A Pc的硬件
Appendix A 附录A PC hardware Pc的硬件 This appendix describes personal computer (PC) hardware, the platfo ...
- 分享一种容易理解的js去重排序方法
<script> var arr=[1,8,6,4,88,22,99,4,6,86,5,58,89,5]; //先使用sort()函数去重 var a=arr.sort(function ...