如何创建一个脚本来查询Google Browserlocation [英] How to create a script to query Google Browserlocation

查看:73
本文介绍了如何创建一个脚本来查询Google Browserlocation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出从Google的浏览器位置API获取地理位置数据的方法。我找到了 JSON,CURL和Google的地理位置,并使其工作至接入点范围内,但我有限的cli-fu不会让我把它分解成我可以发送给Google的东西。



到目前为止,我已经



$ $ $ $ $ $ c $ nmcli -f SSID,BSSID,SIGNAL dev wifi列表
SSID BSSID信号
ElisaKoti73 00:0C:C3:7F :7E:64 66
Kanala 00:1E:AB:56:84:3F 65
TW-EAV510v236E3 00:1E:AB:09:36:E4 44
WLAN-AP 00: 1E:AB:04:C5:C5 32
meduusan verkko 00:1E:AB:54:C4:E0 25
Koti_E8BC EE:43:F6:99:E8:BC 22
Inteno_E1 00:22:07:13:6A:E0 19

现在我想把它变成类似于

  https://maps.googleapis.com/maps/api/browserlocation/json?browser=firefox&sensor=真&安培; 
wifi = mac:00:0C:C3:7F:7E:64 | ssid:ElisaKoti73 | ss:66&

编辑:根据@hotmultimedia的答案进行调整,我得到

   curlhttps://maps.googleapis.com/maps/api/browserlocation/json?browser=firefox&sensor=true& --data-urlencodenmcli -f SSID,BSSID,SIGNAL dev wifi list | perl -neif(s /^(.+?)\s +(..:..:..:..: :..)\s +(+)\s * $ /&安培;无线= MAC:\2 | SSID:\1 | SS:?\3&安培/克){打印;}`  



现在这种方式可行,但准确性不高:准确性:11178 。令人费解的是,如果我在浏览器中复制粘贴相同的地址,返回的JSON就完美无缺,准确性为准确性:52 。任何想法?

解决方案

以下是如何使用(稍微不优化:))Perl oneliner完成此转换: p>

  perl -neif(s /^(.+?)\s+(..:..:..: :..:..)\s +(+)\s * $ / HTTPS:?\ / \ / maps.googleapis.com\ / maps\ / api\ / browserlocation\ / json?browser = firefox& sensor = true& wifi = mac:\ 2 | ssid:\ 1 | ss:\ 3& \\\
/ g){print;}


I'm trying to figure out a way to get geolocation data from Google's Browser location API. I found JSON, CURL and Google's geolocation, and have it working as far as list of access points in range, but my limited cli-fu won't let me parse this into something I can send to Google.

So far, I have

nmcli -f SSID,BSSID,SIGNAL  dev wifi list
SSID             BSSID              SIGNAL 
ElisaKoti73      00:0C:C3:7F:7E:64  66     
Kanala           00:1E:AB:56:84:3F  65     
TW-EAV510v236E3  00:1E:AB:09:36:E4  44     
WLAN-AP          00:1E:AB:04:C5:C5  32     
meduusan verkko  00:1E:AB:54:C4:E0  25     
Koti_E8BC        EE:43:F6:99:E8:BC  22     
Inteno_E1        00:22:07:13:6A:E0  19

What I now want to turn that into is something like

https://maps.googleapis.com/maps/api/browserlocation/json?browser=firefox&sensor=true&
wifi=mac:00:0C:C3:7F:7E:64|ssid:ElisaKoti73|ss:66&

Edit: adapting from the answer by @hotmultimedia, I got to

curl "https://maps.googleapis.com/maps/api/browserlocation/json?browser=firefox&sensor=true&" --data-urlencode "`nmcli -f SSID,BSSID,SIGNAL dev wifi list |perl -ne "if(s/^(.+?)\s+(..:..:..:..:..:..)\s+(.+?)\s*$/&wifi=mac:\2|ssid:\1|ss:\3&/g){print;}"`"

Now this works, but the accuracy is way off: "accuracy" : 11178. Bafflingly, if I copy-paste the same address in my browser, the returned JSON is perfectly fine with an accuracy of "accuracy" : 52. Any ideas?

解决方案

Here's how you can accomplish this transformation using a (slightly non-optimal :)) Perl oneliner:

perl -ne "if(s/^(.+?)\s+(..:..:..:..:..:..)\s+(.+?)\s*$/https:\/\/maps.googleapis.com\/maps\/api\/browserlocation\/json?browser=firefox&sensor=true&wifi=mac:\2|ssid:\1|ss:\3&\n/g){print;}"

这篇关于如何创建一个脚本来查询Google Browserlocation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆