Skip to content

Instantly share code, notes, and snippets.

@spaghetti-
Created July 23, 2012 16:59
Show Gist options
  • Save spaghetti-/3164713 to your computer and use it in GitHub Desktop.
Save spaghetti-/3164713 to your computer and use it in GitHub Desktop.
if re.match('^[0-9\.]*$', sys.argv[1], re.I):
key = ''
xmlsauce = 'http://api.ipinfodb.com/v3/ip-city/?key=' + key + '&ip=' + sys.argv[1] + '&format=xml'
parser = BeautifulSoup(urllib.urlopen(xmlsauce), features = 'xml')
if parser.statusCode.text == 'OK':
data = dict({'ccode': parser.countryCode.text, 'country':parser.countryName.text,
'region':parser.regionName.text, 'city': parser.cityName.text, 'zipcode':parser.zipCode.text,
'time':parser.timeZone.text})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment