|
|||||||
Get my country by IP in bash
Время создания: 09.04.2014 13:45
Раздел: root - Linux - Console - bash
Запись: Yurons/mytetra/master/base/1397040357vhj6mo0gky/text.html на raw.github.com
|
|||||||
|
|||||||
Use another IP locator than ifconfig.me that provides with that information like: curl -s 'http://geoiplookup.net/geoapi.php?output=countrycode'
or: curl -s 'http://geoiplookup.net/geoapi.php?output=country'
(see the API for details) or: curl -s http://whatismycountry.com/ |
sed -n 's|.*,\(.*\)</h1>|\1|p'
or: curl -s http://whatismycountry.com/ |
sed -n 's|.*> *\(.*\)</h1>|\1|p'
for more precision, or: curl -s http://whatismycountry.com/ |
sed -n 's/.*Coordinates \(.*\)<.*/\1/p'
for the coordinates. That makes assumptions on the HTML formatting of the page. So it may stop working if they decide to change that format in the future. |