Skip to content

Instantly share code, notes, and snippets.

@Robotto
Created July 24, 2014 22:06
Show Gist options
  • Save Robotto/8f5937a446aeeb9e39d9 to your computer and use it in GitHub Desktop.
Save Robotto/8f5937a446aeeb9e39d9 to your computer and use it in GitHub Desktop.
Requests demo
#!/usr/bin/env python
import requests
ip='90.185.22.1'
url='http://ipinfo.io/%s/loc'%ip
request = requests.get(url)
#lat = request.text.split(r',', 1)[0]
#lon = request.text.split(r',', 1)[1]
[lat,lon] = request.text.split(r',', 1) #split at the first comma, assign first part to 'lat', second part to 'lon'
print 'lat: %s'%lat
print 'lon: %s'%lon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment