Created
June 22, 2016 18:27
-
-
Save notionparallax/b73be97574e5ac8d721c3dce64530e88 to your computer and use it in GitHub Desktop.
My twitter name is a bit long. I was wondering if there were any good, shorter ones out there. This is a naive way of finding out, but it gets banned by twitter pretty quickly.
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
| #example response: {"valid":false,"reason":"taken","msg":"Username has already been taken","desc":"That username has been taken. Please choose another."} | |
| permissableChars = list("abcdefghijklmnopqrstuvwxyz_1234567890") | |
| import json | |
| import urllib2 | |
| import itertools | |
| possibleUsernames = [] | |
| for i in range(4,5): | |
| options = itertools.combinations(permissableChars, i) | |
| for o in options: | |
| uname = "".join(o) | |
| url = "https://twitter.com/users/username_available?username="+uname | |
| response = urllib2.urlopen(url) | |
| data = response.read() | |
| values = json.loads(data) | |
| print uname, values | |
| if values["valid"] == "true": | |
| print "\n\n\n WE GOT ONE!" | |
| print uname, values | |
| possibleUsernames.push(uname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment