multipost with teratail.
https://teratail.com/questions/111320
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)[0] 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
570 Who developed the "avformat-59.dll" that comes with FFmpeg?
614 Uncaught (inpromise) Error on Electron: An object could not be cloned
580 PHP ssh2_scp_send fails to send files as intended
569 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
903 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.