This script automates the process of posting images to Twitter/X. I created this for my Twitter account.
- Automatically uploads images to Twitter/X
- Adds titles and hashtags to tweets
- Uses a persistent Chrome session to avoid repeated logins
- Skips already processed images to avoid duplicates
- Python 3.6+
undetected-chromedriver
selenium
-
Clone the repository or download the script files.
-
Navigate to the project directory.
-
Install the required packages using the following command:
pip install -r requirements.txt
- YEAR_FOLDER: Path to the folder containing your images.
- USER_DATA_DIR: Path to your Chrome user data directory.
- HASHTAGS: Hashtags to be added to the tweets.
- MAX_TWEETS_PER_RUN: Maximum number of tweets to process in one run (default is 10).
- TEXT_FILE_NAME: Name of the text file containing additional details for the tweets (default is
details.txt
).
-
Ensure that the required configurations are set in the script.
-
Run the script using the following command:
python x.py
-
The script will open a Chrome browser and navigate to Twitter/X.
-
If this is the first time running the script, you will be prompted to log in to Twitter/X. After logging in, press Enter to continue.
-
The script will process up to the specified number of images from the configured folder, uploading them to Twitter/X and adding the necessary details.
-
After processing the images, you will be prompted to publish the tweets manually. Press Enter to continue.
-
The script will save the processed images to the log file and exit.
If you would like to contribute to this project, please email mukhbit000@gmail.com.
This project is licensed under the MIT License. See the LICENSE file for details.