Tweet回复tweepy

时间:2015-01-20 21:56:52

标签: python twitter tweepy

我正在尝试用Python创建一个脚本,用Tweepy在Twitter上回复某些关键字。我在Google上找到了这段代码并试用了它。出于某种原因,Python屏幕自动关闭而不做任何事情。

代码:

#!/usr/bin/env python
import tweepy
#from our keys module (keys.py), import the keys dictionary
from keys import keys

CONSUMER_KEY = keys['consumer_key']
CONSUMER_SECRET = keys['consumer_secret']
ACCESS_TOKEN = keys['access_token']
ACCESS_TOKEN_SECRET = keys['access_token_secret']

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)

twt = api.search(q="Hello World!")     

#list of specific strings we want to check for in Tweets
t = ['Hello world!',
    'Hello World!',
    'Hello World!!!',
    'Hello world!!!',
    'Hello, world!',
    'Hello, World!']

for s in twt:
    for i in t:
        if i == s.text:
            sn = s.user.screen_name
            m = "@%s Hello!" % (sn)
            s = api.update_status(m, s.id)
我做错了什么?我试图在模块中打开它,但我明白了:

>>> ================================ RESTART ================================

我不是编码员或编程人员,但我想知道如何使其工作。 谢谢,

0 个答案:

没有答案