Sinisterly

Full Version: Challenge: Python IP Checker
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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()
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)
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
(12-16-2015, 03:00 PM)meow Wrote: [ -> ]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

It doesn't have to look different. It just has to work. Smile