0% found this document useful (0 votes)
25 views3 pages

Message

Uploaded by

ritamus32
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views3 pages

Message

Uploaded by

ritamus32
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

import time

import requests
from colorama import Fore
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import undetected_chromedriver as uc
from selenium.webdriver.support.ui import Select

API_BASE_URL = "https://api.tempmail.lol/v2"

# Function to create a temporary email


def create_temp_email():
url = f"{API_BASE_URL}/inbox/create"
try:
response = requests.post(url)
if response.status_code == 201:
data = response.json()
email = data.get("address")
print(Fore.GREEN + f"✅ Temporary Email Created: {email}")
return email, data.get("token")
else:
print(Fore.RED + f"❌ Failed to create temporary email. Response:
{response.text}")
return None, None
except requests.RequestException as e:
print(Fore.RED + f"❌ Error creating email: {e}")
return None, None

# Function to check the inbox for new emails


def check_inbox(token):
url = f"{API_BASE_URL}/inbox"
params = {"token": token}
try:
response = requests.get(url, params=params)
if response.status_code == 200:
data = response.json()
if not data.get("emails"):
return []
else:
return data["emails"]
else:
print(Fore.RED + f"❌ Failed to check inbox. Response: {response.text}")
return []
except requests.RequestException as e:
print(Fore.RED + f"❌ Error checking inbox: {e}")
return []

# Function to extract the verification code from the email subject


def extract_verification_code(email):
email_subject = email.get('subject', '')
if email_subject:
code_parts = email_subject.split()
if code_parts and code_parts[0].isdigit():
return code_parts[0]
print(Fore.RED + "❌ Verification code not found in subject.")
return None
def main():
email, token = create_temp_email()

if email:
options = uc.ChromeOptions()
driver = uc.Chrome(options=options)
driver.get("https://x.com/i/flow/signup")

# Use WebDriverWait to ensure the page is loaded properly


WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH,
"//button[contains(., 'Create account')]")))

create_account_button = driver.find_element(By.XPATH, "//button[contains(.,


'Create account')]")
create_account_button.click()

name_field = driver.find_element(By.CSS_SELECTOR, 'input[name="name"]')


email_field = driver.find_element(By.CSS_SELECTOR, 'input[name="email"]')
name_field.send_keys("TestUser")
email_field.send_keys(email)

Select(driver.find_element(By.ID, "SELECTOR_1")).select_by_value("1") #
January
Select(driver.find_element(By.ID, "SELECTOR_2")).select_by_value("1") #
Day 1
Select(driver.find_element(By.ID, "SELECTOR_3")).select_by_value("2000") #
Year 2000
time.sleep(2)

next_button = driver.find_element(By.XPATH, "//button[contains(.,


'Next')]")
next_button.click()

# Check inbox for verification code


verification_code = None
while not verification_code:
emails = check_inbox(token)
if emails:
for email in emails:
verification_code = extract_verification_code(email)
if verification_code:
break
time.sleep(4)

# Enter verification code


if verification_code:
verification_field = driver.find_element(By.NAME, "verfication_code")
verification_field.send_keys(verification_code)
driver.find_element(By.XPATH, "//button[contains(., 'Next')]").click()
print(Fore.GREEN + f"✅ OTP {verification_code} submitted
successfully.")

# Password step
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME,
"password")))
password_field = driver.find_element(By.NAME, "password")
password_field.send_keys("Chorus100$")
time.sleep(2)
driver.find_element(By.XPATH, "//button[contains(., 'Sign up')]").click()
# Skip Avatar step with WebDriverWait
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,
"//button[@data-testid='ocfSelectAvatarSkipForNowButton']"))).click()
time.sleep(2)

# Skip Username step with WebDriverWait


WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,
"//button[@data-testid='ocfEnterUsernameSkipButton']"))).click()
time.sleep(2)

# Skip Final step


WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,
"//button[contains(., 'Skip for now')]"))).click()
time.sleep(2)

# Click next button on settings page


WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,
"//button[@data-testid='ocfSettingsListNextButton']"))).click()
time.sleep(2)

# Follow topics
topics = ["Entertainment", "Music", "Sports"]
for topic in topics:
topic_button = driver.find_element(By.XPATH, f"//div[@aria-
label='Follow {topic} Topic']")
topic_button.click()
time.sleep(2)

# Follow button
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,
"//button[.//span[contains(text(), 'Follow')]]"))).click()
time.sleep(2)

# User Recommendations
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,
"//button[@data-testid='ocfURTUserRecommendationsNextButton']"))).click()
time.sleep(2)

# Wait for redirection to home page


while True:
current_url = driver.current_url
if current_url == "https://x.com/home":
cookies = driver.get_cookies()
print(Fore.CYAN + "🍪 Auth Token Generated:")
for cookie in cookies:
if cookie['name'] == 'auth_token': # Print auth token only
print(cookie['value'])

break
time.sleep(5)

driver.quit()

if __name__ == "__main__":
main()

You might also like