3

我正在使用 Tweepy 下载约 27,000 名用户的推文。我在 3 天前运行了脚本,它运行了好几个小时都没有问题。我停止运行它 2 天,然后当我去重新启动它时,我不得不添加一小部分,因为我忘记在对用户时间线的调用中包含转发。

然而,现在,当我运行它时,它会随机运行一段时间(有时它会运行 3 个用户,有时会运行 100 个用户,不止于此,介于两者之间)。每次,在某些时候它会说:

[Errno 8] nodename nor servname provided, or not known

我不知道这是什么原因造成的。谷歌搜索它会从其他库中找到大量内容,但与 Tweepy 无关。这只是网络问题(连接断开)还是 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)
4

1 回答 1

2

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.

于 2014-03-13T19:15:17.293 回答