For many channels, this works perfectly. However, ocassionally I’ll come across a user that will only return 198 or so tweets out of 200. Obviously this is not a big difference and not a big deal, but I’m wondering if there’s any reason why this could be? Thank you!
def parse(channels,n):
print("Getting tweets...")
objList=[]
for x in range(len(channels)):
channel=channels[x]
page = 1
while page<=n:
statuses = None
try:
statuses = api.user_timeline(page=page, id=channel,count=200, include_rts=True)
except:
renew_time = time.strftime("%H:%M:%S", time.gmtime(api.rate_limit_status()['resources']['statuses']['/statuses/user_timeline']['reset']-21600))
sys.exit("Oops! Rate limit exceeded. Try again at: " + str(renew_time + " CST."))
if statuses:
count=0
for status in statuses:
txt = status["text"]
text_clean = re.sub(r"(?:\@|https?\:\/\/)\S+", "URL", txt)
newTweet = Tweet(text_clean,channel)
objList.append(newTweet)
count=count+1
print(count)
page += 1
return objList