I'm using Tweepy to download tweets from ~27,000 users. I ran the script 3 days ago, and it ran for many hours without a problem. I stopped running it for 2 days and then when I went to go restart it, I had to add a small piece since I forgot to include retweets in the call to a user's timeline.
Now however, when I run it, it will run for some random amount of time (sometimes it will do 3 users, sometimes it will do 100 users, more than that, somewhere inbetween). Every time, at some point it will say:
[Errno 8] nodename nor servname provided, or not known
I don't know what's causing this. Googling for it turns up tons of stuff from other libraries but nothing pertaining to Tweepy. Is this just a network issue (connection dropping) or is there something wrong with Tweepy?
CONSUMER_KEY = '**'
CONSUMER_SECRET = '**'
ACCESS_KEY = '**'
ACCESS_SECRET = '**'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
bill_authors = [id1, id2, id3, ...]
for author in bill_authors:
try:
for status in tweepy.Cursor(api.user_timeline, id=author, include_rts=True).items():
lowerb = datetime.datetime(2012, 8, 26, 0, 1)
upperb = datetime.datetime(2012, 8, 30, 0, 1)
if status.created_at >= lowerb and status.created_at <= upperb:
print '%s - %s - %s - %s' % (status.id, status.created_at, author, status.text)
if status.created_at < lowerb:
break
except tweepy.TweepError, e:
print 'Error! %s' % (e)
This is definitely nothing to do with your code. The error suggests it might be a DNS problem, or some other network issue. I doubt this has anything to do with Tweepy, so I would recommend retrying your script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With