2

我有来自同一帐户的推文 url 列表,我想检查这些推文是否仍然存在。

如果 twitter 以此类错误响应,则一条推文可能不再存在:

This Tweet is from an account that no longer exists. Learn more

或者

Sorry that page doesn't exist!

或任何此类错误。

我尝试使用 twint 库从给定的配置文件中抓取所有推文,并检查我的“推文列表”上的推文是否也在 twint 库的结果中。

我已经使用此功能使用 twint 抓取所有推文:

def get_tweets(username):
    c = twint.Config()
    c.Username = username
    tweets = []
    c.Store_object = True
    c.Retweets = True
    c.Store_object_tweets_list = tweets
    c.Hide_output = True
    twint.run.Profile(c)
    tweets_links = []
    for tweet in tweets:
        tweets_links.append(tweet.link)
    return tweets_links
get_tweets(username)

这很好用,但问题是它不会抓取所有推文,并且会在某个日期停止(对于我正在测试的用户名“GideonCRozner”,它会在 2020 年 6 月 24 日停止),并且我有帖子网址在该日期之前。所以很简单,我无法使用 twint 库抓取所有帖子。

我现在的解决方案是包含selenium在代码和get尚未被一一抓取的帖子中,但正如您所知,selenium 是一个较慢的解决方案。

所以我希望我可以利用你的一些想法,刮掉所有用户的推文或测试一条推文,如果它没有硒并且没有 Twitter API

非常感谢您的时间!

4

0 回答 0