multipost with teratail.
Tired of spam accounts that indiscriminately like my tweets on Twitter, I tried to automatically block them on python's tweet
I was thinking about it, but I'm having a hard time because I don't know how to get the tweet ID of the person who liked my tweet.
I think I translated the API reference for tweet through automatic translation, but the method to get the tweet ID of the person who liked it is
I thought it didn't exist.
If there is such a method, please let me know.
Also, please let me know if there is another way to get it.
I have already configured various keys, and I have created an API instance to get my tweets and their IDs.
Eventually, it automatically blocks accounts with 21 followers among those who have liked my tweets on python's tweet
I would like to make it into a script.
Thank you for your cooperation.python twitter
As you looked into it yourself, there seems to be no way to get a list of users who liked it in the official API. There was someone who wrote his own Python code, so would this be helpful?
How to "get a user who likes" that does not exist in TwitterAPI
import urlib.request import re # # https://stackoverflow.com/questions/28982850/twitter-api-getting-list-of-users-who-favorited-a-status def get_favoritters(post_id): try: json_data=urlib.request.urlopen('https://twitter.com/i/activity/favorited_popup?id='+str(post_id)) .read() json_data=json_data.decode("utf8") found_ids=re.findall(r'data-user-id=\\"+\d+',json_data) unique_ids = list(set([re.findall(r'\d+', match) for match in found_ids])) return unique_ids except urllib.request.HTTPError: return False
Also, as mentioned in the comments in the code, if you use the above URL, please look at the English version of SO and see
It appears that the code was rewritten for Python 3.x.The original question was for Python 2.x.
Twitter API-Getting list of users who favorite a status-Stack Overflow
366 Is there any other way to save the Python database?
355 Unity Virtual Stick Does Not Return to Center When You Release Your Finger
353 I want to create an array of sequences from "1" to a specified number.
345 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2023 OneMinuteCode. All rights reserved.