0

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?

1 Answer 1

1

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;}"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.