Is there a way to get all the user id retweeted for a particular tweet using tweet?

Asked 2 years ago, Updated 2 years ago, 59 views

Nice to meet you.
Currently, I am thinking of using python's tweet (3.9.0) for data analysis.
So I have a question.As stated in the title, I would like to know how to get all the user id retweeted for a particular tweet.It's all about it. If there are 1000 retweets, I'd like to get 1000 user id.I can get the user id itself, but I can't get all of it.Below is the code I tried.

import tweet

CONSUMER_KEY = ' 〇 〇 〇 〇 〇 ''
CONSUMER_SECRET = '✕✕✕✕✕✕✕✕✕✕ ' '✕✕NS CO'
ACCESS_TOKEN=' 〇 〇 〇 〇 〇 〇 ' 〇'
ACCESS_TOKEN_SECRET=' '✕✕✕✕✕✕✕✕✕✕✕✕✕✕✕ '✕✕ECCC A S✕ TO✕'

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)

retweeters1 = tweet.Cursor(api.retweeters, id=1234567890).Items()
retweeters2=api.retweeters(id=1234567890, cursor=-1)

I couldn't get all the retweeter1 and 2 cases.Please let me know what kind of code I should write to get all the items.
Also, I didn't really understand the meaning of Cursor, so I would appreciate it if you could let me know as well.
Thank you for your cooperation.

python twitter

2022-09-30 11:32

1 Answers

The same goes for browser access, but if there are more than a certain number of results, the page will be split.
If you want to get all the results like this, you can use the for loop to repeat them.

The code snippet on the following page contains several samples, so I think these will be helpful. (I don't usually write Python myself, so I'll just introduce the sample.)

Code snippet — tweet 3.6.0 Documentation

This snippet follows all followers of an authenticated user

.
for follower intweepy.Cursor(api.followers).items():
    follower.follow()

"Also, regarding ""Cursor"", the following explanation may be helpful."

Cursor Tutorial—tweepy 3.6.0 Documentation

Twitter API development uses a lot of pageation.Page/cursor parameters must be specified for each request to perform paging that iterates through timelines, user lists, direct messages, etc.The problem here is that many boilerplate codes are needed to manage the pageation loop.To simplify page numbers and reduce the amount of code required, Tweepy has a Cursor object.

Also, please refer to the official document if necessary, as the link above will be translated into Japanese by volunteers.


2022-09-30 11:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.