Advertisement
redsees

Untitled

Jan 30th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. #!/usr/bin/env python2
  2. try:
  3.     import bitly_api,sys,urllib2,urllib,os,re,random,json
  4. except ImportError,err:
  5.     print "[~]Missing Module(s) !"
  6.     print "[~]%s ." % err
  7.     exit(0)
  8. def bitly_usage(x):
  9.     print """
  10. #######################################
  11. ###           PyBitly v0.1          ###
  12. #######################################
  13.  
  14. Usage : %s <url>
  15.  
  16. Example :
  17. %s www.google.com/
  18.  
  19. Author  : Abdullah Mohamed
  20. Contact : secmania{at}hotmail{dot}com
  21. """ % (x,x)
  22.  
  23. user="redsees"
  24. api_key="R_dd22db5ed31a9c75cac1a478eaf016b8"
  25. bitly=bitly_api.Connection(user,api_key)
  26. if len(sys.argv) != 2 :
  27.     bitly_usage(sys.argv[0])
  28.     sys.exit(0)
  29. bitly_usage(sys.argv[0])
  30. url=sys.argv[1]
  31. if url.find("http://")!=0:
  32.     url="http://"+url
  33. try:
  34.     bitly.shorten(url)['url']
  35. except bitly_api.bitly_api.BitlyError:
  36.     print "[~]Invalid URI !"
  37.     print "[~]Exiting ... \n\n"
  38.     sys.exit(0)
  39. print "\n\n[~]Original URL  :  %s " % (url)
  40. print "[~]Shortened URL : ",
  41. print bitly.shorten(url)['url']
  42. print "\n\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement