Skip to content

Instantly share code, notes, and snippets.

@phagenlocher
Created January 31, 2019 11:28
Show Gist options
  • Select an option

  • Save phagenlocher/a36d9ba29b920e537b817645a0e6d2dc to your computer and use it in GitHub Desktop.

Select an option

Save phagenlocher/a36d9ba29b920e537b817645a0e6d2dc to your computer and use it in GitHub Desktop.
Get IP and Location from ifconfic.co
#!/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