twitter crawling _ python.
I used a " time.sleep ", but I get an error.
tweepy.error.TweepError: Twitter error response: status code = 429
What should I do?
import tweepy
import time
import os
search_term = 'word1'
search_term2= 'word2'
search_term3='word3'
lat = "37.6"
lon = "127.0"
radius = "100km"
API_key = "44"
API_secret = "33"
Access_token = "22"
Access_token_secret = "11"
location = "%s,%s,%s" % (lat, lon, radius)
auth = tweepy.OAuthHandler(API_key, API_secret)
auth.set_access_token(Access_token, Access_token_secret)
api = tweepy.API(auth)
c=tweepy.Cursor(api.search,
q="{}+OR+{}".format(search_term, search_term2, search_term3),
rpp=1000,
geocode=location,
include_entities=True)
data = {}
i = 1
for tweet in c.items():
data['text'] = tweet.text
print(i, ":", data)
i += 1
time.sleep(300)
I have additional questions
The following is a code that stores the output results as a txt file
Does this code require " time.sleep "?
wfile = open(os.getcwd()+"/workk2.txt", mode='w')
data = {}
i = 0
for tweet in c.items():
data['text'] = tweet.text
wfile.write(data['text']+'\n')
i += 1
time.sleep(300)
wfile.close()