]>
jfr.im git - irc/rizon/acid.git/blob - pyva/src/main/python/internets/api/ipinfo.py
2 from feed
import XmlFeed
5 def __init__(self
, api_key
):
9 def get_info(self
, target
):
10 url
= 'http://api.ipinfodb.com/v3/ip-city/?key=%s&format=xml&' % self
.api_key
11 url
+= urllib
.urlencode({'ip': target}
)
13 r
= reply
.elements('/Response')[0]
15 'ip_addr': r
.text('ipAddress'),
16 'status': r
.text('statusMessage'),
17 'country_code': r
.text('countryCode', 'N/A'),
18 'country_name': r
.text('countryName', 'N/A').capitalize(),
19 'region': r
.text('regionName', 'N/A').capitalize(),
20 'city': r
.text('cityName', 'N/A').capitalize(),
21 'zip': r
.text('zipCode', 'N/A'),
22 'latitude': r
.text('latitude'),
23 'longitude': r
.text('longitude'),
24 'timezone': r
.text('timezone', 'N/A')