我正在运行此代码以提取以获取推文。但运行此代码会给我一个Syntaxerror : unexpected EOF while parsing
。我是python的新手,所以任何帮助表示赞赏!提前谢谢。
from TwitterSearch import *
try:
tso = TwitterSearchOrder()
tso.setKeywords(['xyz', 'abc'])
tso.setLanguage('de') # we want to see German tweets only
tso.setCount(7) # please dear Mr Twitter, only give us 7 results per page
tso.setIncludeEntities(False) # and don't give us all those entity information
ts = TwitterSearch(
consumer_key = 'a',
consumer_secret = 'b',
access_token = 'c',
access_token_secret = 'd'
)
for tweet in ts.searchTweetsIterable(tso):
print('@%s tweeted: %s' % (tweet['user']['screen_name'], tweet['text']))
答案 0 :(得分:0)
在脚本末尾需要一个except块:
except Exception, e:
print str(e)
除了打印异常并继续前进之外,我建议做一些事情,但这是基本布局。