Advertisement
Guest User

Untitled

a guest
Jul 26th, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import tweepy
  2.  
  3. consumer_key = ""
  4. consumer_secret = ""
  5. key = ""
  6. secret = ""
  7.  
  8. auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
  9. auth.set_access_token(key, secret)
  10.  
  11. api = tweepy.API(auth, retry_count=10, retry_delay=5, retry_errors=set([401, 404, 500, 503]), wait_on_rate_limit=True)
  12. c = tweepy.Cursor(api.search,q="mongodb",include_entities=True,rpp=100).items()
  13.  
  14. import jsonpickle
  15. import json
  16.  
  17.  
  18.  
  19. counter = 0
  20. while True:
  21. try:
  22. tweet = c.next()
  23. tweet = jsonpickle.encode(tweet)
  24. tweet = json.loads(tweet)
  25. col.insert(tweet)
  26. counter += 1
  27. print ("TweetNumber %s " % counter )
  28. except tweepy.TweepError:
  29. time.sleep(60 * 15)
  30. continue
  31. except StopIteration:
  32. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement