Tweepy 人物搜索和从 python 中搜索返回的人物列表

Tweepy people search and list of people returned from search in python

我正在尝试从 Twitter 上按名称搜索获取所有搜索结果。

任何人都可以帮助我如何使用 tweepy 列出 Python

中按名称搜索的所有搜索结果的所有用户、个人简介、关注者数量

parse_list 是一个包含所有用户名(更具体的屏幕名称)的列表,您可以通过如下代码获取他们的信息 and/or 记录:

for sname in parse_list:
    try:
        user_tweets = api.user_timeline(screen_name = sname, tweet_mode = 'extended', lang='en', count=100, include_rts=True)
    except tweepy.error.TweepError:
        print("Failed to run the command on that user, Skipping...")
        continue
#   user_tweets = tweepy.Cursor(api.user_timeline, screen_name=sname, tweet_mode = 'extended', lang='en').items(20)
    print(str(count)+" "+sname)
    for t in user_tweets:
        if hasattr(t, 'retweeted_status'):
            author = t.retweeted_status.user.screen_name
        else: author = t.user.screen_name
        user_id = t.user.id
        user_name = t.user.name
        user_screenName = t.user.screen_name
        user_text = t.full_text
        #user_text = re.sub(r"http\S+", "", user_text)
        user_text = re.sub(r'https?:\/\/.*[\r\n]*', '', user_text, flags=re.MULTILINE) 
        user_text.replace("\n"," ").replace("\r"," ").replace("|"," ").replace(" | "," ").replace("?"," ")
        user_text = ' '.join(user_text.split())
        user_timestamp = t.created_at
        user_retweet = t.retweet_count
        user_favorite = t.favorite_count
        userframe = [user_id,user_name,user_screenName, author,user_text,user_timestamp,user_retweet,user_favorite]
        mega_tweet_list.append(userframe)

userframe 中存储了您可能要查找的所有个人简介。如果您需要 more/other 个数据点,请考虑在 google 上搜索 "twitter Introduction to JSON object",您应该会找到您感兴趣的信息点类型。