使用Tweety中的user_timeline按文本过滤推文

时间:2017-12-28 03:09:28

标签: python api text twitter tweepy

我正在尝试使用“api.user_timeline”关键字过滤我从某个帐户获得的结果,所以基本上我希望程序忽略该帐户中没有该关键字的推文推文,但我似乎无法找到解决方案。

source_file.cpp(16): error C3855: 'N1::Other': template parameter 'T' is incompatible with the declaration
source_file.cpp(24): note: see reference to class template instantiation 'N1::MyClass<T>::Dependencies' being compiled
source_file.cpp(29): note: see reference to class template instantiation 'N1::MyClass<T>' being compiled
source_file.cpp(20): error C3203: 'Other': unspecialized class template can't be used as a template argument for template parameter 'T', expected a real type

是不是:(?)

import time

for tweet in tweepy.Cursor(api.user_timeline, since='2017-12-27',
                           screen_name='example').items(2):
    try:
        if not tweet.retweeted:
            tweet.retweet()
            m = "@example This is an example."
            t = api.update_status(status=m, in_reply_to_status_id=tweet.id)
            print("Example, Working...")
            time.sleep(5)
    except tweepy.TweepError as e:
        print(e.reason)
        time.sleep(5)
        break
    except StopIteration:
        break

我真的不知道,所以任何帮助都非常感谢!

1 个答案:

答案 0 :(得分:2)

if not tweet.retweeted:
    if "keyword" in tweet.text:
        doThis()

您可能还希望使用string.lower()对此不区分大小写。