├── import these ├── README.md └── tiktok.py /import these: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | import time 3 | from selenium.webdriver.common.keys import Keys 4 | from selenium.webdriver.chrome.options import Options 5 | import options 6 | import io 7 | import sys 8 | from selenium.common.exceptions import NoSuchElementException 9 | import pyautogui 10 | from selenium.webdriver.support.ui import WebDriverWait 11 | from selenium.webdriver.common.by import By 12 | from selenium.webdriver.support import expected_conditions as EC 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tiktok-mass-comment 2 | simple bot that will mass comment for you 3 | edit webdriver location 4 | now run code once, youll get an error. the first time you run it you will get an error because there is no tiktok account logged in. 5 | login on tiktok even if the script stopped because of an error. 6 | in order for this to work you must be AFK 7 | you are free to do anything you want with this code. 8 | WINDOW MUST BE MAIXMISED FOR THIS TO WORK 9 | 10 | there are some minor issues with this i plan to fix. 11 | -------------------------------------------------------------------------------- /tiktok.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | import time 3 | from selenium.webdriver.common.keys import Keys 4 | from selenium.webdriver.chrome.options import Options 5 | import options 6 | import io 7 | import sys 8 | from selenium.common.exceptions import NoSuchElementException 9 | import pyautogui 10 | from selenium.webdriver.support.ui import WebDriverWait 11 | from selenium.webdriver.common.by import By 12 | from selenium.webdriver.support import expected_conditions as EC 13 | 14 | 15 | 16 | chrome_options = Options() 17 | options = webdriver.ChromeOptions() 18 | options.add_experimental_option("excludeSwitches", ["enable-logging"]) 19 | options.add_argument("user-data-dir=C:\\Users\\gabri\\Local\Google\\Chrome\\") 20 | options.add_argument('--profile-directory=Profile 1') #Path to your chrome profile 21 | 22 | user_agent = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' 23 | options.add_argument("user-agent="+user_agent) 24 | 25 | driver = webdriver.Chrome(options=options, executable_path=r'C:\Program Files (x86)\Chrome\Application\chromedriver.exe') 26 | tik = driver.get('https://tiktok.com') 27 | wait = WebDriverWait(driver, 2) 28 | 29 | 30 | time.sleep(2) 31 | driver.maximize_window() 32 | 33 | 34 | def main(): 35 | for x in range(0, 6): 36 | driver.find_element_by_xpath('/html/body/div/div/div[2]/div[2]/div/div/main/div/div[1]/span[1]/div/div/div[5]/div[2]/div[2]').click() 37 | time.sleep(2) 38 | 39 | try: 40 | wait.until(EC.presence_of_all_elements_located((By.XPATH, '/html/body/div/div/div[2]/div[2]/div/div/main/div/div[2]/div[2]/div[2]/div[3]/div'))) 41 | except TimeoutException: 42 | print('comments are disabled or there are no comments') 43 | driver.get('https://tiktok.com') 44 | main() 45 | try: 46 | wait.until(EC.presence_of_all_elements_located((By.CLASS_NAME, 'jsx-2175848453 disable-text'))) 47 | 48 | except: 49 | print('video isnt limited or has no comments, commenting.') 50 | pyautogui.click(1508,1006) 51 | pyautogui.write(comment1) 52 | time.sleep(2) 53 | driver.find_element_by_xpath('/html/body/div/div/div[2]/div[2]/div/div/main/div/div[2]/div[2]/div[3]/div/div[2]').click() 54 | driver.back() 55 | time.sleep(2) 56 | driver.find_element_by_xpath('/html/body/div[3]/div/div/div[2]/button[1]').click() 57 | driver.get('https://tiktok.com') 58 | 59 | def main2(): 60 | for x in range(0, 6): 61 | driver.find_element_by_xpath('/html/body/div/div/div[2]/div[2]/div/div/main/div/div[1]/span[1]/div/div/div[5]/div[2]/div[2]').click() 62 | time.sleep(2) 63 | 64 | try: 65 | wait.until(EC.presence_of_all_elements_located((By.XPATH, '/html/body/div/div/div[2]/div[2]/div/div/main/div/div[2]/div[2]/div[2]/div[3]/div'))) 66 | except TimeoutException: 67 | print('comments are disabled or there are no comments') 68 | driver.get('https://tiktok.com') 69 | main() 70 | try: 71 | wait.until(EC.presence_of_all_elements_located((By.CLASS_NAME, 'jsx-2175848453 disable-text'))) 72 | 73 | except: 74 | print('video isnt limited or has no comments, commenting.') 75 | pyautogui.click(1508,1006) 76 | pyautogui.write(comment2) 77 | time.sleep(2) 78 | driver.find_element_by_xpath('/html/body/div/div/div[2]/div[2]/div/div/main/div/div[2]/div[2]/div[3]/div/div[2]').click() 79 | driver.back() 80 | time.sleep(2) 81 | driver.find_element_by_xpath('/html/body/div[3]/div/div/div[2]/button[1]').click() 82 | driver.get('https://tiktok.com') 83 | 84 | 85 | 86 | 87 | def main3(): 88 | for x in range(0, 6): 89 | driver.find_element_by_xpath('/html/body/div/div/div[2]/div[2]/div/div/main/div/div[1]/span[1]/div/div/div[5]/div[2]/div[2]').click() 90 | time.sleep(2) 91 | 92 | try: 93 | wait.until(EC.presence_of_all_elements_located((By.XPATH, '/html/body/div/div/div[2]/div[2]/div/div/main/div/div[2]/div[2]/div[2]/div[3]/div'))) 94 | except TimeoutException: 95 | print('comments are disabled or there are no comments') 96 | driver.get('https://tiktok.com') 97 | main() 98 | try: 99 | wait.until(EC.presence_of_all_elements_located((By.CLASS_NAME, 'jsx-2175848453 disable-text'))) 100 | 101 | except: 102 | print('video isnt limited or has no comments, commenting.') 103 | pyautogui.click(1508,1006) 104 | pyautogui.write(comment3) 105 | time.sleep(2) 106 | driver.find_element_by_xpath('/html/body/div/div/div[2]/div[2]/div/div/main/div/div[2]/div[2]/div[3]/div/div[2]').click() 107 | driver.back() 108 | time.sleep(2) 109 | driver.find_element_by_xpath('/html/body/div[3]/div/div/div[2]/button[1]').click() 110 | driver.get('https://tiktok.com') 111 | 112 | 113 | print('do not enter duplicate comments or you will be limited to comment.') 114 | print('bot will not comment on a video with no comments to avoid looking spammyx') 115 | comment1 = input('Comment 1: ') 116 | comment2 = input('Comment 2: ') 117 | comment3 = input('Comment 3: ') 118 | 119 | body = driver.find_element_by_tag_name('body') 120 | 121 | if body.is_displayed(): 122 | main() 123 | 124 | else: 125 | print('error loading page') 126 | --------------------------------------------------------------------------------