ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.57k stars 1.14k forks source link

Not able to use it with tiktok? #404

Open luad1234 opened 2 years ago

luad1234 commented 2 years ago

I'm running the script below, but I'm unable to log in because I keep getting the error message "Too many attempts. Try again later." Am I using the script wrong, or is the script simply not able to bypass TikTok?

`import time import random import requests from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import NoSuchElementException from webdriver_manager.chrome import ChromeDriverManager as CM import undetected_chromedriver.v2 as uc import undetected_chromedriver as uc

print('=====================================================================================================') print('Heyy, you have to login manully on tiktok, so the bot will wait you 1 minute for loging in manually!') print('=====================================================================================================') time.sleep(8) print('Running bot now, get ready and login manually...') time.sleep(4)

bot = uc.Chrome() options = webdriver.ChromeOptions() bot = webdriver.Chrome(options=options, executable_path=CM().install()) bot.set_window_size(1680, 900)

bot.get('https://www.tiktok.com/login') ActionChains(bot).key_down(Keys.CONTROL).send_keys( '-').key_up(Keys.CONTROL).perform() ActionChains(bot).key_down(Keys.CONTROL).send_keys( '-').key_up(Keys.CONTROL).perform() print('Waiting 50s for manual login...') time.sleep(50) bot.get('https://www.tiktok.com/upload/?lang=en') time.sleep(3)

def check_exists_by_xpath(driver, xpath): try: driver.find_element_by_xpath(xpath) except NoSuchElementException: return False

return True

def upload(video_path): while True: file_uploader = bot.find_element_by_xpath( '//*[@id="main"]/div[2]/div/div[2]/div[2]/div/div/input')

    file_uploader.send_keys(video_path)

    caption = bot.find_element_by_xpath(
        '//*[@id="main"]/div[2]/div/div[2]/div[3]/div[1]/div[1]/div[2]/div/div[1]/div/div/div/div/div/div/span')

    bot.implicitly_wait(10)
    ActionChains(bot).move_to_element(caption).click(
        caption).perform()
    # ActionChains(bot).key_down(Keys.CONTROL).send_keys(
    #     'v').key_up(Keys.CONTROL).perform()

    with open(r"caption.txt", "r") as f:
        tags = [line.strip() for line in f]

    for tag in tags:
        ActionChains(bot).send_keys(tag).perform()
        time.sleep(2)
        ActionChains(bot).send_keys(Keys.RETURN).perform()
        time.sleep(1)

    time.sleep(5)
    bot.execute_script("window.scrollTo(150, 300);")
    time.sleep(5)

    post = WebDriverWait(bot, 100).until(
        EC.visibility_of_element_located(
            (By.XPATH, '//*[@id="main"]/div[2]/div/div[2]/div[3]/div[5]/button[2]')))

    post.click()
    time.sleep(30)

    if check_exists_by_xpath(bot, '//*[@id="portal-container"]/div/div/div[1]/div[2]'):
        reupload = WebDriverWait(bot, 100).until(EC.visibility_of_element_located(
            (By.XPATH, '//*[@id="portal-container"]/div/div/div[1]/div[2]')))

        reupload.click()
    else:
        print('Unknown error cooldown')
        while True:
            time.sleep(600)
            post.click()
            time.sleep(15)
            if check_exists_by_xpath(bot, '//*[@id="portal-container"]/div/div/div[1]/div[2]'):
                break

    if check_exists_by_xpath(bot, '//*[@id="portal-container"]/div/div/div[1]/div[2]'):
        reupload = WebDriverWait(bot, 100).until(EC.visibility_of_element_located(
            (By.XPATH, '//*[@id="portal-container"]/div/div/div[1]/div[2]')))
        reupload.click()

    time.sleep(1)

================================================================

Here is the path of the video that you want to upload in tiktok.

Plese edit the path because this is different to everyone.

upload(r"C:\Users\redi\Videos\your-video-here.mov")

================================================================`

richdevid commented 2 years ago

You can login using QR, same here I can't login using another method.

luad1234 commented 2 years ago

QR is woking for you with my script? not working for me

Azru44 commented 2 years ago

Hey, same problem, anyone has found a solution please?

2fersen commented 2 years ago

i can login with facebook

But i can't insert a title, class can't be found, xpath and css selector want work. Your path is also dont working

Also the button to release the video isn't working, i really dont understand what i am doing wrong. driver.find_element(By.CSS_SELECTOR, 'button[class="tiktok-btn-pc-tiktok-btn-pc-large-tiktok-btn-pc-primary"]').click() driver.find_element(By.XPATH, '//*[@id="root"]/div/div/div/div/div[3]/div[2]/div[8]/button[2]').click()

jpratt9 commented 7 months ago

has anyone solved this? I was able to get it to the login screen, type in the email/password, & hit the submit button, but then it prompts me with a captcha