iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📖

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-webdriver gem must be installed.
  • ChromeDriver must be installed and added to your system's PATH.

Setup

  1. Clone from this repository.

https://github.com/linkalls/twitter-bookmark-img-save

Next, cd twitter-bookmark-img-save

  1. Replace the placeholders in the twittersc.rb script with your actual Twitter username and password.

  2. Install the required gem.

    gem install selenium-webdriver
    
  3. Download ChromeDriver and add it to your system's PATH.
    (You can find how to do this by searching online.)
    [Reference]

https://www.google.com/search?q=Chrome用WebDriver&oq=Chrome用WebDriver&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIKCAEQABiABBiiBDIKCAIQABiABBiiBDIGCAMQRRg90gEHMzAxajBqNKgCALACAA&sourceid=chrome&ie=UTF-8

Usage

  1. Run the script from the command line with the following command:

    ruby twittersc.rb
    
  2. When the script is executed, it automatically logs in to Twitter, navigates to the bookmarks page, and saves the image URLs to tbu.txt.

  3. To download the images, run the following command:

    ruby urltoimg.rb
    

    Or, 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