Closed 742617000027 closed 3 years ago
That's right. You should catch both TwitterRequestError
and TwitterConnectionError
. You can also check for messages. Something like this...
try
r = TwitterPager(api, 'search/tweets', {'q':'pizza', 'count':100})
for item in r.get_iterator():
if 'text' in item:
print item['text']
elif 'message' in item and item['code'] == 88:
print 'SUSPEND, RATE LIMIT EXCEEDED: %s\n' % item['message']
break
except TwitterRequestError as e:
print(e.status_code)
for msg in iter(e):
print(msg)
except TwitterConnectionError as e:
print(e)
Hi! There doesn't seem to be a way to check the status code of a response when using
TwitterPager
, as far as I can see. I ran into this issue when requestingfollowers/ids
of a user I was blocked by. As it seems, the only way around this for now would be to usetry ... except
, since thecursor
attribute doesn't seem to be provided in responses made withoutTwitterPager
. Am I missing something? Cheers!