【发布时间】:2020-11-12 08:51:03
【问题描述】:
我的数据集只有“1300747127350423552”之类的推文 ID,我可以在 Python 中搜索这些推文吗? 我试过这段代码:
tweet = api.statuses_lookup(['1300747127350423552']) a1[0].文本
但是没有用。
【问题讨论】:
-
什么不起作用 - 您看到的错误是什么?
我的数据集只有“1300747127350423552”之类的推文 ID,我可以在 Python 中搜索这些推文吗? 我试过这段代码:
tweet = api.statuses_lookup(['1300747127350423552']) a1[0].文本
但是没有用。
【问题讨论】:
我可以使用 TWEEPY 搜索该 ID 并获得结果。出于隐私考虑,我将避免发布结果。
import tweepy
def searchtweet():
twitter_auth_keys = {
"consumer_key": "yours goes here",
"consumer_secret": "yours goes here",
"access_token": "yours goes here",
"access_token_secret": "yours goes here"
}
auth = tweepy.OAuthHandler(
twitter_auth_keys['consumer_key'],
twitter_auth_keys['consumer_secret']
)
auth.set_access_token(
twitter_auth_keys['access_token'],
twitter_auth_keys['access_token_secret']
)
api = tweepy.API(auth)
print(api.statuses_lookup(["INSERT YOUR SEARCH TWEET ID HERE"]))
def main():
searchtweet()
【讨论】: