Advertisement
Guest User

meowCow

a guest
Feb 5th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. #
  3. # This is a VERY simple non-elegant Python script to scrape a Twitter Accounts
  4. # followers! Could EASILY be modified to scrape those _following_ the account.
  5. # You'll need your OWN twitter OAuth keys.... login to http://apps.twitter.com
  6. # to set this up.... ALSO you'll need to install the python tweepy module..
  7. # because we are using the tweepy module to interact with the twitter API
  8. # So.. from a command prompt do: pip3 install tweepy
  9. #
  10. # As far as I know tweepy only works on python3
  11. #
  12. #
  13. # A couple of caveats: Twitters API throttles certain requests... So, when using
  14. # this script on a user with lots of followers you WILL hit the "rate limit"
  15. # at this point the script will stop and wait 15 minutes for the next "window"
  16. # Please DO NOT quit the script.. just let it do it's thing... it WILL resume
  17. # and continue scraping. If you can run the script on Googles App Engine
  18. # You can comment out the section relating to the the rate limit as there IS
  19. # no rate limit when running on their servers.. however you may start using a lot
  20. # of CPU cycles on your APP engine account and end up getting charged.. it's up to
  21. # you... make the decision yourself.
  22. #
  23. #
  24. #
  25.  
  26.  
  27. import time
  28. import tweepy
  29.  
  30. # insert your Twitter keys here
  31. consumer_key ='turyg3mVmnkXi2YDcYLRUUGLm'
  32. consumer_secret='CMbOA6zauAsaF5H4TCg8TWX54dejumsK2Aw9IZDGAKqAbmN68V'
  33. access_token='4867989411-1LyFLBrxUxBKEdE7Mx9Kk6qFgMdprO0CRy9RcIi'
  34. access_secret='aEIU3qjlNBOYUqfG83bIqswAIvDhJPc4tebXNgpnhZXnf'
  35.  
  36. auth = tweepy.auth.OAuthHandler(consumer_key, consumer_secret)
  37. auth.set_access_token(access_token, access_secret)
  38. api = tweepy.API(auth)
  39.  
  40. userINP=input( "Enter the Twitter screen name : " )
  41.  
  42.  
  43. #This writes a file named 'USERNAME_YOU_ENTERED.txt' to the same directory you
  44. # have the script in - you can give it a path, if you like!
  45. with open('{}.txt'.format(userINP),'w') as list:
  46.  
  47. # Login
  48. if(api.verify_credentials):
  49. print ('We are logged in!')
  50.  
  51. user = tweepy.Cursor(api.followers, screen_name=userINP).items()
  52. x=1
  53. while True:
  54. try:
  55. print ('Scraping.... ')
  56. u = next(user, False)
  57. list.write('twitter.com/{}\n'.format(u.screen_name))
  58. print ('Scraped twitter.com/{}'.format(u.screen_name))
  59. print ('Added to list DaeshBAG Number: {}\n'.format(x))
  60. x+=1
  61. #time.sleep(2*1)
  62. except KeyboardInterrupt:
  63. print (' <--- You pressed Ctrl-C - Program terminated. File not written to disk!')
  64. break
  65. except tweepy.error.TweepError:
  66. print ('Houston, We have a problem! We may have reached the Twatter API rate limit')
  67. print ('We are now forced to wait 15 minutes for next window.. Blame Twatter! \n')
  68. time.sleep(15*60)
  69. #continue
  70. except:
  71. if u is False:
  72. print ('Done! Now pastebin the contents of the list in this directory!')
  73. print ('Post the pastebin url in #opISIS-Targets')
  74. print ('for addition to the botnet...')
  75. print ('Have a coffee and do it again!')
  76. print ('Don\'t run the script too many times consecutively')
  77. print ('or you\'ll run into rate limit problems.. 4 or 5 times an hour!')
  78. quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement