├── LICENSE ├── README.md └── g.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Yashu_Krish11 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Twitter-auto-tweets-with-multiple-accounts 2 | Twitter auto tweets with multiple accounts using selenium with python 3 | 4 | # Here, I have added up to 5 accounts which will auto-login and auto-tweet in twitter 5 | 6 | # Change the random words if you want different words. 7 | 8 | # Must change username and password field.. 9 | 10 | # change how much tweet needed ... 11 | 12 | # Note: For auto-login, the accounts used must be non-authentication accounts 13 | 14 | Download the latest version of chromedriver from https://chromedriver.chromium.org/. After downloading, extract the file and place it in the same folder as the "g.py" file. 15 | 16 | Note: Do not use accounts with two-factor authentication. 17 | 18 | To run the script, open the command prompt in the folder and enter "g.py" or double-click on the "g.py" file to start the automated process. 19 | 20 | # 👉 Note: Every time Twitter updates the code, it varies. So press 'Ctrl+Shift+C' to open the developer tools, and inspect and fork it.. 21 | 22 | 23 | 👉Note:- 24 | 25 | 👉if your selenium version is in latest version then the code never run 26 | 27 | 👉open cmd and enter pip uninstall selenium 28 | 29 | And enter 30 | 31 | pip install selenium==4.2.1 or pip install selenium==4.2.0 32 | 33 | and hit enter 34 | 35 | and 36 | 37 | python -c "import selenium; print(selenium.version)" 38 | 39 | 𝙏𝙝𝙞𝙨 𝙞𝙣𝙛𝙤𝙧𝙢𝙖𝙩𝙞𝙤𝙣 𝙞𝙨 𝙤𝙣𝙡𝙮 𝙛𝙤𝙧 𝙚𝙙𝙪𝙘𝙖𝙩𝙞𝙤𝙣al 𝙥𝙪𝙧𝙥𝙤𝙨𝙚 𝙖𝙣𝙙 𝙬𝙚 𝙖𝙧𝙚 𝙣𝙤𝙩 𝙧𝙚𝙨𝙥𝙤𝙣𝙨𝙞𝙗𝙡𝙚 𝙛𝙤𝙧 𝙖𝙣𝙮 𝙠𝙞𝙣𝙙 𝙤𝙛 𝙞𝙡𝙡𝙚𝙜𝙖𝙡 𝙖𝙘𝙩𝙞𝙫𝙞𝙩𝙮 𝙙𝙤𝙣𝙚 𝙗𝙮 𝙩𝙝𝙞𝙨 𝙩𝙤𝙤𝙡. 40 | -------------------------------------------------------------------------------- /g.py: -------------------------------------------------------------------------------- 1 | #upto 5 accounts you can auto tweet for more add more twitter username and password in list 2 | from selenium import webdriver 3 | from selenium.webdriver.common.by import By 4 | from selenium.webdriver.common.keys import Keys 5 | from selenium.webdriver.support.ui import WebDriverWait 6 | from selenium.webdriver.support import expected_conditions as EC 7 | from selenium.common.exceptions import NoSuchElementException, TimeoutException 8 | import time 9 | import random 10 | 11 | # List of Twitter accounts (replace with valid credentials) 12 | accounts = [ 13 | {"username": "Twitter123", "password": "Twitter_12345"}, 14 | {"username": "Twitter456", "password": "Twitter_67890"}, 15 | {"username": "Twitter789", "password": "Twitter_11223"}, 16 | {"username": "Twitter321", "password": "Twitter_44556"}, 17 | {"username": "Twitter654", "password": "Twitter_77889"} 18 | ] 19 | 20 | # List of comments to tweet 21 | commentsDict = [ 22 | 'good', 'amazing one', 'keep going', 'excellent', 'next video please', 23 | 'sub to your channel', 'shared to others', 'made my day', 'keep it up', 24 | 'sensational', 'rock it', 'challenge it', 'post video daily', 25 | 'work was amazing', 'needed more edit', 'edit was awesome', 26 | 'what a video man', 'watched yesterday', 'your are genius', 27 | 'faster than light', 'your work needed success', 'new fan of you', 28 | 'keep rock dude', 'copy cat', 'link the video', 'listening', 29 | 'writing', 'reading', 'playing' 30 | ] 31 | 32 | def login_and_tweet(account): 33 | """Logs into Twitter and posts tweets.""" 34 | driver = webdriver.Chrome() 35 | driver.maximize_window() 36 | 37 | try: 38 | driver.get("https://twitter.com/compose/tweet") 39 | time.sleep(5) 40 | 41 | # Login process 42 | email = driver.find_element(By.NAME, 'text') 43 | email.send_keys(account["username"]) 44 | email.send_keys(Keys.ENTER) 45 | time.sleep(2) 46 | 47 | password = driver.find_element(By.NAME, 'password') 48 | password.send_keys(account["password"]) 49 | password.send_keys(Keys.ENTER) 50 | time.sleep(3) 51 | 52 | # Tweet posting loop (up to 5 tweets per account) 53 | for _ in range(5): # Change 5 to the desired tweet count 54 | try: 55 | tweet_box = driver.find_element(By.XPATH, '//div[@data-testid="tweetTextarea_0"]') 56 | tweet_box.send_keys(random.choice(commentsDict)) 57 | time.sleep(1) 58 | 59 | post_button = driver.find_element(By.XPATH, '//span[text()="Post"]') 60 | post_button.click() 61 | time.sleep(2) 62 | 63 | except Exception as e: 64 | print(f"Error posting tweet for {account['username']}: {e}") 65 | break 66 | 67 | except Exception as e: 68 | print(f"Error logging in for {account['username']}: {e}") 69 | 70 | finally: 71 | time.sleep(2) 72 | driver.quit() 73 | 74 | # Loop through accounts and post tweets 75 | for acc in accounts: 76 | login_and_tweet(acc) 77 | 78 | --------------------------------------------------------------------------------