从twitter获取数据时出错

时间:2012-09-14 15:16:50

标签: python twitter

import twitter
api=twitter.Api()
page=1
count=0
while(page<=2):
    tweets=api.GetSearch("#ghaza",per_page=200)
    twitterapi.until:2011-05-09
    for k in tweets:
        print k.text

    page+=1

我运行代码,代码在我没有输入twitterapi.until:2011-05-09时正确运行但是我想要有关特定日期的数据,但它给出了科学错误。我在https://dev.twitter.com/docs/using-search上注意到上面的代码语法。

1 个答案:

答案 0 :(得分:1)

如果查看文档,您会发现until将在搜索查询中使用。

此处您对until:的使用违反了Python语法,因为冒号用于 功能与类定义,条件和循环。并且twitterapi.until也将是未定义的。

所以,我相信您应该将tweets=api.GetSearch("#ghaza",per_page=200)更改为tweets=api.GetSearch("#ghaza until:2011-05-09",per_page=200)。如果api中的select查询是"#ghaza"