Advertisement
Juju_rh

Untitled

May 25th, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. #coding: utf-8
  2. #!/usr/bin/env python
  3. # -*- coding: UTF-8 -*-
  4. from __future__ import absolute_import, print_function, unicode_literals
  5. import tweepy
  6. import sys
  7. import os
  8. import io, json
  9. from pprint import pprint
  10. import time
  11. import jsonpickle
  12.  
  13. auth = tweepy.AppAuthHandler('','')
  14.  
  15. api = tweepy.API(auth,wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
  16.  
  17. if (not api):
  18.    print("problem connection to API")
  19.  
  20. api.rate_limit_status()['resources']['search']
  21. searchQuery = 'place:08b2d74428e2ca88 "مرحبا" OR "السلام" '
  22.  
  23. maxTweets = 100 #1000000
  24. searched_tweets = [status._json for status in tweepy.Cursor(api.search, q=searchQuery).items(maxTweets)]
  25. json_strings = [json.dumps(json_obj, ensure_ascii=False) for json_obj in searched_tweets]
  26. tweetCount = 0
  27. with io.open ('SAUDI.json','w', encoding = 'utf-8') as f:
  28.      for tweet in json_strings:
  29.             json.dump(tweet, f, ensure_ascii= False)
  30.             tweetCount += 1
  31. print("Downloaded {0} tweets".format(tweetCount))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement