Created
May 5, 2013 20:48
-
-
Save kylestev/5522119 to your computer and use it in GitHub Desktop.
Get your IP from MaxMind using the requests and bs4 libraries in Python
This file contains hidden or 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
| from bs4 import BeautifulSoup | |
| from requests import Session | |
| MAXMIND_URL = 'http://www.maxmind.com/en/locate_my_ip' | |
| def get_ip(sesh): | |
| soup = BeautifulSoup(sesh.get(MAXMIND_URL).content) | |
| return soup.find(id='my-ip-address').text | |
| if __name__ == '__main__': | |
| print get_ip(Session()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment