Created
July 24, 2014 22:06
-
-
Save Robotto/8f5937a446aeeb9e39d9 to your computer and use it in GitHub Desktop.
Requests demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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