我用tweepy挖掘用户时间线数据,并且在理解以下方面遇到了一些困难:
感谢您的帮助.
我正在使用tweepy流API来获取包含特定主题标签的推文.我面临的问题是我无法从Streaming API中提取推文的全文.只有140个字符可用,之后会被截断.
这是代码:
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
def analyze_status(text):
if 'RT' in text[0:3]:
return True
else:
return False
class MyStreamListener(tweepy.StreamListener):
def on_status(self, status):
if not analyze_status(status.text) :
with open('fetched_tweets.txt','a') as tf:
tf.write(status.text.encode('utf-8') + '\n\n')
print(status.text)
def on_error(self, status):
print("Error Code : " + status)
def test_rate_limit(api, wait=True, buffer=.1):
"""
Tests whether the rate limit of the last request has been reached.
:param api: The `tweepy` api instance.
:param wait: A flag indicating whether to wait …Run Code Online (Sandbox Code Playgroud)