mirror of
https://github.com/chubin/wttr.in
synced 2025-01-12 12:08:47 +00:00
Remove lat, long from _ip2location because WS5 is more expensive
This commit is contained in:
parent
1b25e16a37
commit
c49c0a5c0e
1 changed files with 4 additions and 3 deletions
|
@ -153,15 +153,16 @@ def _ip2location(ip_addr):
|
|||
return None
|
||||
try:
|
||||
r = requests.get(
|
||||
'http://api.ip2location.com/?ip=%s&key=%s&package=WS5'
|
||||
'http://api.ip2location.com/?ip=%s&key=%s&package=WS3' # WS5 provides latlong
|
||||
% (ip_addr, IP2LOCATION_KEY))
|
||||
r.raise_for_status()
|
||||
location = r.text
|
||||
if location and ';' in location:
|
||||
ccode, country, region, city, lat, long, *_ = location.split(';')
|
||||
# ccode, country, region, city, lat, long, *_ = location.split(';')
|
||||
ccode, country, region, city, *_ = location.split(';')
|
||||
except requests.exceptions.RequestException:
|
||||
return None
|
||||
return city, region, country, ccode, lat, long
|
||||
return city, region, country, ccode # , lat, long
|
||||
|
||||
|
||||
def _ipinfo(ip_addr):
|
||||
|
|
Loading…
Reference in a new issue