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)
|
'ip': str(ipaddr)
|
||||||
}
|
}
|
||||||
content = self.browser.readurl(self.browser.buildurl('http://www.geolocalise-ip.com/api.php', **args))
|
content = self.browser.readurl(self.browser.buildurl('http://www.geolocalise-ip.com/api.php', **args))
|
||||||
tab = {}
|
tab = {'ville' : NotAvailable ,\
|
||||||
tab['ville'] = NotAvailable
|
'region' : NotAvailable ,\
|
||||||
tab['region'] = NotAvailable
|
'cp' : NotAvailable ,\
|
||||||
tab['cp'] = NotAvailable
|
'pays' : NotAvailable ,\
|
||||||
tab['pays'] = NotAvailable
|
'lt' : NotAvailable ,\
|
||||||
tab['lt'] = NotAvailable
|
'lg' : NotAvailable ,\
|
||||||
tab['lg'] = NotAvailable
|
'host' : NotAvailable ,\
|
||||||
tab['host'] = NotAvailable
|
'tld' : NotAvailable ,\
|
||||||
tab['tld'] = NotAvailable
|
'fai' : NotAvailable}
|
||||||
tab['fai'] = NotAvailable
|
|
||||||
|
|
||||||
for line in content.split('&'):
|
for line in content.split('&'):
|
||||||
if not '=' in line:
|
if not '=' in line:
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,13 @@ class IpinfodbBackend(BaseBackend, ICapGeolocIp):
|
||||||
""" exception"""
|
""" exception"""
|
||||||
raise Exception('Bad parameter')
|
raise Exception('Bad parameter')
|
||||||
else:
|
else:
|
||||||
tab = {}
|
tab = {'City' : 'NA' ,\
|
||||||
|
'Country name' : 'NA' ,\
|
||||||
|
'Region' : 'NA' ,\
|
||||||
|
'Latitude' : 'NA' ,\
|
||||||
|
'Longitude' : 'NA' ,\
|
||||||
|
'hostname' : 'NA' ,\
|
||||||
|
'zipcode' : 'NA'}
|
||||||
line = ''
|
line = ''
|
||||||
for line in content.split('\n'):
|
for line in content.split('\n'):
|
||||||
if '<li>' in line:
|
if '<li>' in line:
|
||||||
|
|
@ -65,7 +71,7 @@ class IpinfodbBackend(BaseBackend, ICapGeolocIp):
|
||||||
iploc = IpLocation(ipaddr)
|
iploc = IpLocation(ipaddr)
|
||||||
iploc.city = tab['City'].decode('utf-8')
|
iploc.city = tab['City'].decode('utf-8')
|
||||||
iploc.region = tab['Region']
|
iploc.region = tab['Region']
|
||||||
iploc.zipcode = 'NA'
|
iploc.zipcode = tab['zipcode']
|
||||||
iploc.country = tab['Country name']
|
iploc.country = tab['Country name']
|
||||||
iploc.lt = float(tab['Latitude'])
|
iploc.lt = float(tab['Latitude'])
|
||||||
iploc.lg = float(tab['Longitude'])
|
iploc.lg = float(tab['Longitude'])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue