![]() |
|
Challenge: Python IP Checker - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Python (https://sinister.li/Forum-Python) +--- Thread: Challenge: Python IP Checker (/Thread-Challenge-Python-IP-Checker) |
Challenge: Python IP Checker - Megan - 12-14-2015 Your mission is to write a python script that gets the users external IP and then saves it to a local text file. I use checkip.dyndns.org to find out my external IP you can use alternatives! I'll re-write my own personal script for this in python. RE: Challenge: Python IP Checker - m0dem - 12-14-2015 Done. It's probably the same as you though. Code: import urllib2
i=urllib2.urlopen("http://myip.dnsdynamic.org/").read()
f=open("i.txt", "w")
f.write(i)
f.close()RE: Challenge: Python IP Checker - Inori - 12-16-2015 this isn't python, but it works (school's ip, I don't care who has it) Code: curl 'https://api.ipify.org'|tee 'ip.txt'in python: Code: from requests import get
open('ip.txt','w').write(get('https://api.ipify.org').text)RE: Challenge: Python IP Checker - meow - 12-16-2015 How is this a challenge? Code: import urllib2
ip=urllib2.urlopen('https://icanhazip.com').read()
f=open('ip.txt', 'w')
f.write(ip)
print ip+"Written to file 'ip.txt'"
f.close()EDIT: just realized my solution looks almost exactly like m0dem's, guess ill make it seem a little different RE: Challenge: Python IP Checker - m0dem - 12-16-2015 (12-16-2015, 03:00 PM)meow Wrote: How is this a challenge? It doesn't have to look different. It just has to work.
|