📜 ⬆️ ⬇️

Determine your location via WiFi network

Simple script. Identifies the location. You need to work via Wifi.

iwlist wlan0 scan | sed -n 's /.* Address: // p; T; s / // g; q' |
sed 's /.*/ {version: 1.1.0, host: maps.google.com, request_address: true, address_language:' $ {LANG /.*/} ', wifi_towers: [{mac_address: "&", signal_strength : 8, age: 0}]} / '|
curl -sX POST -d @ - www.google.com/loc/json |
sed -e 'h; s /.* latitude ": \ ([^,] * \). * / \ 1 /; G; s / \ n [^ \ n] * longitude": \ ([^,] * \). * /, \ 1 \ n /; s | ^ | http: //maps.google.com/maps? Q = |; x; s / [, {] / \ n / g; s / [ "}] // g; s /: / \ t / g; s / \ n //; G '

Do not forget to put curl.
')
In my case, I correctly identified the city and the street, I made a mistake with the house number at 4.

How it works? Google collects information about where the access points are located (by MAC).
The first part (iwlist wlan0 scan | sed-n 's /.* Address: // p; T; s / // g; q') is just a poppy definition.

Source: https://habr.com/ru/post/116575/


All Articles