我正在尝试从Twitter上的名称搜索中获取所有搜索结果。
任何人都可以帮助我如何使用tweepy列出Python中按名称搜索的所有搜索结果的所有用户,生物,关注者的人数
答案 0 :(得分:0)
parse_list
是一个包含所有用户名(更具体地说是屏幕名称)的列表,您可以通过编码如下代码来获取其信息和/或记录:
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
中。如果您需要更多/其他数据点,请考虑在Google上搜索“ JSON对象的twitter简介”,然后应该找到您感兴趣的信息点的类型。