Skip to content

Instantly share code, notes, and snippets.

@0xv
Created August 27, 2012 12:12
Show Gist options
  • Save 0xv/3487910 to your computer and use it in GitHub Desktop.
Save 0xv/3487910 to your computer and use it in GitHub Desktop.
check available username on twitter
#!/usr/bin/env python
'''@0xv'''
import json, urllib2
user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1'
username = raw_input('username: ')
url = 'https://www.twitter.com/users/username_available?suggest=1&username=%s&full_name=&email=&suggest_on_username=true&context=front&custom=1' % (username)
req = urllib2.Request(url)
get = urllib2.urlopen(req).read()
resp = json.loads(get)
if "available" in resp["reason"]:
print '[+] %s %s' % (username, resp["msg"])
elif "error" in resp:
print '[!] %s %s' % (username, resp["msg"])
else:
print '[-] %s %s' % (username, resp["msg"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment