Created
January 22, 2014 16:56
-
-
Save shriphani/8562447 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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