iTranslated by AI
Building a Ruby Script to Automatically Collect and Save X (Twitter) Bookmark Images (Part 1)
Why I posted this
I decided to write this up and publish it mainly because when I posted about writing this script on my personal Instagram, it received quite a bit of feedback.
Prerequisites
- Ruby must be installed.
- The
selenium-webdrivergem must be installed. - ChromeDriver must be installed and added to your system's PATH.
Setup
- Clone from this repository.
Next, cd twitter-bookmark-img-save
-
Replace the placeholders in the
twittersc.rbscript with your actual Twitter username and password. -
Install the required gem.
gem install selenium-webdriver -
Download ChromeDriver and add it to your system's PATH.
(You can find how to do this by searching online.)
[Reference]
Usage
-
Run the script from the command line with the following command:
ruby twittersc.rb -
When the script is executed, it automatically logs in to Twitter, navigates to the bookmarks page, and saves the image URLs to
tbu.txt. -
To download the images, run the following command:
ruby urltoimg.rbOr, if you want to save them with sequential numbering, run the following command:
ruby urltoimgnum.rb
Precautions
- This script may violate Twitter's Terms of Service. Please use it at your own risk.
- The script runs in an infinite loop. You will need to stop it manually to exit. (I have a feeling it might end even without manual intervention.)
Final Thoughts
I hope this helps everyone transitioning from X (Twitter) to platforms like Misskey.
Discussion