Skip to content

Commit

Permalink
Merge pull request simonfarah#101 from terafear/main
Browse files Browse the repository at this point in the history
  • Loading branch information
simonfarah authored Mar 5, 2024
2 parents 0a8106c + ee383ea commit 61dbf30
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 90 deletions.
60 changes: 45 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,52 @@
## TikTok Bot
# TikTok Bot

### Requirements
This Python-based TikTok Bot automates various interactions on [Zefoy](https://zefoy.com/), such as increasing followers, hearts, views, shares, and more, using Selenium to navigate and interact with the website. The script is designed for educational purposes to demonstrate automation and web scraping techniques.

- Python 3.x
- Have [chrome](https://www.google.com/chrome/) installed
- Install the required modules (cd into the code directory and run this command)
## Features

pip install -r requirements.txt
- Automated interactions on TikTok to increase followers, hearts, views, shares, and favorites.
- Utilizes Selenium for automation.
- Interactive CLI for easy use and navigation through the bot's features.

### How to use
## Prerequisites

1. Run the `bot.py` file
2. Wait till the driver opens, and solve the captcha
3. The driver will be minimized and you can continue working while the bot do its job
- [Python 3.x](https://www.python.org/downloads/)
- [Google Chrome browser](https://www.google.com/chrome/)
- Internet connection

### Disclaimer
## Installation

- This tool is for educational purposes only
- Do not use it for illegal work or without the consent of the tiktok account owner
- I am not responsible for any action taken using this script
- I am not responsible for any damage of any kind for using this script
1. Clone the repository to your local machine.
2. Install Google Chrome if not already installed.
3. Navigate to the cloned directory and install the required Python packages:

```sh
pip install -r requirements.txt
```

## Usage

1. Open a terminal or command prompt.
2. Navigate to the project's directory.
3. Run the bot with the following command:

```sh
python bot.py
```

4. Follow the CLI prompts to complete captchas and choose the service you want to automate (e.g., followers, hearts).
5. Input the URL of the video you want to apply the service to when prompted.

## Disclaimer

This tool is created for educational purposes only. The developer assumes no liability for any misuse or damage caused by this tool. It is the end user's responsibility to comply with all applicable local, state, national, and international laws.

- **Ethical Use**: Use this bot responsibly and ethically. Do not use it to spam or harm other users.
- **Consent**: Ensure you have the consent of the account holder before using this bot on any account.
- **No Warranty**: This software is provided "as is", without warranty of any kind.

By using this software, you agree to the terms of this disclaimer and to provided license.

## Contributions

Contributions are welcome! If you have suggestions for improvements or bug fixes, please feel free to fork the repository and submit a pull request.
144 changes: 70 additions & 74 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from os import system
from time import sleep
from colorama import init, Fore
import undetected_chromedriver as uc
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import NoSuchElementException

init(autoreset=True)
Expand All @@ -10,19 +15,21 @@
class Bot:
def __init__(self):
system("cls || clear")

self.printBanner()

print(Fore.YELLOW + "[~] Loading driver, please wait...")

try:
self.driver = uc.Chrome()
except:
print(Fore.RED + "[!] No internet connection")
exit()
options = Options()
options.add_argument(
"--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
)
self.driver = webdriver.Chrome(options=options)

print(Fore.GREEN + "[+] Driver loaded succesfully")
print()
print(Fore.GREEN + "[+] Driver loaded successfully")
print()
except Exception as e:
print(Fore.RED + f"[!] Error loading driver: {e}")
exit()

self.url = "https://zefoy.com"
self.captcha_xpath = "/html/body/div[5]/div[2]/form/div/div/div/div/button"
Expand Down Expand Up @@ -67,15 +74,17 @@ def start(self):
print()

self.wait_for_xpath(self.captcha_xpath)

print(Fore.YELLOW + "[~] Please complete the captcha")

self.wait_for_xpath(self.services["followers"]["xpath"])
print(Fore.GREEN + "[+] Captcha completed sucessfully")

print(Fore.GREEN + "[+] Captcha completed successfully")
print()

self.driver.minimize_window()

self.check_services()

for index, service in enumerate(self.services):
title = self.services[service]["title"]
status = self.services[service]["status"]
Expand All @@ -86,40 +95,18 @@ def start(self):
try:
choice = int(input(Fore.YELLOW + "[-] Choose an option : "))
except ValueError:
pass
continue # This ensures the loop continues after a ValueError

if choice in [1, 2, 3, 4, 5, 6]:
if choice in range(1, 7):
break

if choice == 1: # followers
div = 7
self.driver.find_element(
"xpath", self.services["followers"]["xpath"]
).click()
elif choice == 2: # hearts
div = 8
self.driver.find_element("xpath", self.services["hearts"]["xpath"]).click()
elif choice == 3: # comment hearts
# div = 9
# self.driver.find_element(
# "xpath", self.services["comment_hearts"]["xpath"]
# ).click()
print()
print(Fore.RED + "[!] Comment heart option is not yet available")
exit()
elif choice == 4: # views
div = 10
self.driver.find_element("xpath", self.services["views"]["xpath"]).click()
elif choice == 5: # shares
div = 11
self.driver.find_element("xpath", self.services["shares"]["xpath"]).click()
elif choice == 6: # favorites
div = 12
self.driver.find_element(
"xpath", self.services["favorites"]["xpath"]
).click()
else:
exit()
self.select_service(choice)

def select_service(self, choice):
div = 6 + choice
service_key = list(self.services.keys())[choice - 1]

self.driver.find_element(By.XPATH, self.services[service_key]["xpath"]).click()

print()
video_url = input(Fore.MAGENTA + "[-] Video URL : ")
Expand All @@ -130,61 +117,70 @@ def start(self):
def start_service(self, div, video_url):
url_input_xpath = f"/html/body/div[{div}]/div/form/div/input"
search_btn_xpath = f"/html/body/div[{div}]/div/form/div/div/button"
send_btn_xpath = f"/html/body/div[{div}]/div/div/div[1]/div/form/button"

input = self.driver.find_element("xpath", url_input_xpath)
input.clear()
input.send_keys(video_url)
input_element = self.driver.find_element(By.XPATH, url_input_xpath)
input_element.clear()
input_element.send_keys(video_url)

self.driver.find_element("xpath", search_btn_xpath).click()
while True:
# Click the search button
self.driver.find_element(By.XPATH, search_btn_xpath).click()

sleep(3)
sleep_duration, can_proceed = self.check_submit(div)
# Attempt to click the send button if it's present
try:
WebDriverWait(self.driver, 5).until(
EC.element_to_be_clickable((By.XPATH, send_btn_xpath))
).click()
except TimeoutException:
# If the send button isn't found, click the search button again
self.driver.find_element(By.XPATH, search_btn_xpath).click()

if not can_proceed:
print(Fore.YELLOW + f"[~] Sleeping for {sleep_duration} seconds")
sleep(sleep_duration)
self.driver.find_element("xpath", search_btn_xpath).click()
remaining_time = self.check_remaining_time(div)

send_btn_xpath = f"/html/body/div[{div}]/div/div/div[1]/div/form/button"
self.wait_for_xpath(send_btn_xpath)
self.driver.find_element("xpath", send_btn_xpath).click()
if remaining_time is not None:
print(Fore.YELLOW + f"[~] Sleeping for {remaining_time} seconds")
sleep(remaining_time)

success_message_xpath = f"/html/body/div[{div}]/div/div/span[2]"
self.wait_for_xpath(success_message_xpath)
print(Fore.GREEN + "[+] Sent successfully")
self.start_service(div, video_url)

def check_submit(self, div):
def check_remaining_time(self, div):
remaining_time_xpath = f"/html/body/div[{div}]/div/div/span[1]"

try:
element = self.driver.find_element("xpath", remaining_time_xpath)
element = self.driver.find_element(By.XPATH, remaining_time_xpath)
text = element.text

minutes = element.text.split("Please wait ")[1].split(" ")[0]
seconds = element.text.split("(s) ")[1].split(" ")[0]
sleep_duration = int(minutes) * 60 + int(seconds) + 5
if "Please wait" in text:
minutes = text.split("Please wait ")[1].split(" ")[0]
seconds = text.split(" second")[0].split()[-1]
sleep_duration = int(minutes) * 60 + int(seconds) + 5

return sleep_duration, False
except:
return None, True
return sleep_duration
else:
return None
except NoSuchElementException:
return None

def check_services(self):
for service in self.services:
xpath = self.services[service]["xpath"]
element = self.driver.find_element("xpath", xpath)

if element.is_enabled():
self.services[service]["status"] = Fore.GREEN + "[WORKING]"
else:
try:
element = self.driver.find_element(By.XPATH, xpath)

if element.is_enabled():
self.services[service]["status"] = Fore.GREEN + "[WORKING]"
else:
self.services[service]["status"] = Fore.RED + "[OFFLINE]"
except NoSuchElementException:
self.services[service]["status"] = Fore.RED + "[OFFLINE]"

def wait_for_xpath(self, xpath):
while True:
try:
_ = self.driver.find_element("xpath", xpath)
self.driver.find_element(By.XPATH, xpath)
return True
except NoSuchElementException:
pass
sleep(1)

def printBanner(self):
print(
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
colorama==0.4.4
selenium==4.11.0
undetected_chromedriver==3.5.3

0 comments on commit 61dbf30

Please sign in to comment.