Created
January 31, 2019 11:28
-
-
Save phagenlocher/a36d9ba29b920e537b817645a0e6d2dc to your computer and use it in GitHub Desktop.
Get IP and Location from ifconfic.co
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
| #!/usr/bin/python3 | |
| from json import loads | |
| from requests import get | |
| g = get("https://ifconfig.co/json") | |
| if not g.ok: | |
| print("Failure connecting to ifconfig.co") | |
| exit(-1) | |
| j = loads(g.text) | |
| print(j.get("ip"),"|",j.get("country")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment