corrections on geolocip and ipinfodb
This commit is contained in:
parent
f296b6e0e3
commit
384280c0df
2 changed files with 17 additions and 12 deletions
|
|
@ -48,16 +48,15 @@ class GeolocIpBackend(BaseBackend, ICapGeolocIp):
|
|||
'ip': str(ipaddr)
|
||||
}
|
||||
content = self.browser.readurl(self.browser.buildurl('http://www.geolocalise-ip.com/api.php', **args))
|
||||
tab = {}
|
||||
tab['ville'] = NotAvailable
|
||||
tab['region'] = NotAvailable
|
||||
tab['cp'] = NotAvailable
|
||||
tab['pays'] = NotAvailable
|
||||
tab['lt'] = NotAvailable
|
||||
tab['lg'] = NotAvailable
|
||||
tab['host'] = NotAvailable
|
||||
tab['tld'] = NotAvailable
|
||||
tab['fai'] = NotAvailable
|
||||
tab = {'ville' : NotAvailable ,\
|
||||
'region' : NotAvailable ,\
|
||||
'cp' : NotAvailable ,\
|
||||
'pays' : NotAvailable ,\
|
||||
'lt' : NotAvailable ,\
|
||||
'lg' : NotAvailable ,\
|
||||
'host' : NotAvailable ,\
|
||||
'tld' : NotAvailable ,\
|
||||
'fai' : NotAvailable}
|
||||
|
||||
for line in content.split('&'):
|
||||
if not '=' in line:
|
||||
|
|
|
|||
|
|
@ -46,7 +46,13 @@ class IpinfodbBackend(BaseBackend, ICapGeolocIp):
|
|||
""" exception"""
|
||||
raise Exception('Bad parameter')
|
||||
else:
|
||||
tab = {}
|
||||
tab = {'City' : 'NA' ,\
|
||||
'Country name' : 'NA' ,\
|
||||
'Region' : 'NA' ,\
|
||||
'Latitude' : 'NA' ,\
|
||||
'Longitude' : 'NA' ,\
|
||||
'hostname' : 'NA' ,\
|
||||
'zipcode' : 'NA'}
|
||||
line = ''
|
||||
for line in content.split('\n'):
|
||||
if '<li>' in line:
|
||||
|
|
@ -65,7 +71,7 @@ class IpinfodbBackend(BaseBackend, ICapGeolocIp):
|
|||
iploc = IpLocation(ipaddr)
|
||||
iploc.city = tab['City'].decode('utf-8')
|
||||
iploc.region = tab['Region']
|
||||
iploc.zipcode = 'NA'
|
||||
iploc.zipcode = tab['zipcode']
|
||||
iploc.country = tab['Country name']
|
||||
iploc.lt = float(tab['Latitude'])
|
||||
iploc.lg = float(tab['Longitude'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue