Finds and displays a random webpage from the Internet. (Warning: It may take a while!)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # randomURL.py
# Finds and displays a random webpage.
# FB - 201009127
import random
import urllib2
import os
while(True):
ip0 = str(random.randint(0, 255))
ip1 = str(random.randint(0, 255))
ip2 = str(random.randint(0, 255))
ip3 = str(random.randint(0, 255))
url = 'http://' + ip0 + '.' + ip1 + '.'+ ip2 + '.'+ ip3
print url
try:
urlContent = urllib2.urlopen(url).read()
if urlContent.find('<html') > -1 or urlContent.find('<HTML') > -1:
break
except:
pass
print "Found URL: " + url
os.system('start ' + url)
|