corrections on geolocip and ipinfodb

This commit is contained in:
Julien Veyssier 2010-11-26 12:19:22 +01:00
commit 384280c0df
2 changed files with 17 additions and 12 deletions

View file

@ -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:

View file

@ -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'])