Skip to content

Instantly share code, notes, and snippets.

@shriphani
Created January 22, 2014 16:56
Show Gist options
  • Save shriphani/8562447 to your computer and use it in GitHub Desktop.
Save shriphani/8562447 to your computer and use it in GitHub Desktop.
import random
import requests
import itertools
import json
import time
letters = 'abcdefghijklmnopqrstuvwxyz'
def sample():
return ''.join([random.choice(letters) for _ in range(5)]) + '.com'
def test():
url = 'http://api.statdns.com/XXXX/a'
samples = []
while len(samples) < 1000:
x = sample()
if not x in samples:
samples.append(x)
print len(samples)
succ = 0
fail = 0
for site in samples:
test_url = url.replace('XXXX', site)
time.sleep(1)
try:
print test_url
resp = requests.get(test_url).text
if resp.find('NXDOMAIN') >= 0:
fail += 1
print 'fail'
else:
succ += 1
print 'succ'
except:
fail += 1
print 'fail'
print succ, fail
if __name__ == '__main__':
test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment