如何使用python中的twitter API抓取包含特定链接的推文?

问题描述 投票:0回答:1

我正在使用tweepy库来检索包含特定链接的tweet,但不会返回任何内容。

这里是代码:

####input your credentials here
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth,wait_on_rate_limit=True)


for tweet in tweepy.Cursor(api.search,q='www.democracynow.org/2018/4/18/americas_1_weapons_salesman_trump_promotes', count=10,
                           lang="en",
                           since="2017-04-03").items():
    print (tweet.created_at, tweet.text)

我尝试了普通链接和编码链接,但是都没有用。没有错误,只是空的。

是否有解决方法?

python url twitter tweepy
1个回答
1
投票

如果执行a search on Twitter's website for your query,将会看到没有结果。相反,您可能想搜索"https://www.democracynow.org/2018/4/18/americas_1_weapons_salesman_trump_promotes"

但是,请注意,Twitter的standard search API限制为7天,并且该搜索的所有结果都比该日期早得多。您必须使用高级或企业搜索API才能获得较早的结果。

© www.soinside.com 2019 - 2024. All rights reserved.