khaouitiabdelhakim / Gmail-Creation-Automation-Python

This script allows you to automate the creation of Gmail accounts using the Selenium automation framework with the Chrome WebDriver. It navigates through the Gmail sign-up process by filling in the required details, such as name, username, password, and more.
https://khaouitiapps.vercel.app/
104 stars 32 forks source link

mobile verification problem #7

Open rebazjabar opened 3 months ago

rebazjabar commented 3 months ago

i think if you can switch the web browser to mobile brower the problem will be fix because the mbile browser has skip option

dung13796 commented 2 months ago

@rebazjabar do you try it?

chandlerwilcox88 commented 1 day ago

I tried a mobile emulation and I couldn't get it to display a skip option.

`# Gmail Account Creation Automation Script - Version 1.1.0

Original script by Abdelhakim Khaouiti (khaouitiabdelhakim on GitHub)

Account Creation Automation Script - Version 1.1.0

Original script by Abdelhakim Khaouiti (khaouitiabdelhakim on GitHub)

from selenium import webdriver from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import Select, WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.chrome.options import Options as ChromeOptions import random import time import json import os from unidecode import unidecode

Chrome options

chrome_options = ChromeOptions() chrome_options.add_argument("--disable-infobars") chrome_options.add_argument("--disable-notifications")

Add mobile emulation

mobile_emulation = { "deviceMetrics": { "width": 360, "height": 640, "pixelRatio": 3.0 }, "userAgent": "Mozilla/5.0 (Linux; Android 10; Pixel 3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36" } chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)

Use webdriver_manager to handle ChromeDriver

driver = webdriver.Chrome( service=Service(ChromeDriverManager().install()), options=chrome_options )

def get_next_account_number():

Create file if it doesn't exist

if not os.path.exists('createdAccounts.json'):
    with open('createdAccounts.json', 'w') as f:
        json.dump({'accounts': []}, f)

# Read existing accounts
with open('createdAccounts.json', 'r') as f:
    data = json.load(f)

# Get the next number (1 if no accounts exist)
accounts = data.get('accounts', [])
next_number = len(accounts) + 1

return next_number

def save_account_credentials(username, password): with open('createdAccounts.json', 'r+') as f: data = json.load(f) data['accounts'].append({ 'email': f'{username}@gmail.com', 'password': password, 'created_at': time.strftime('%Y-%m-%d %H:%M:%S') }) f.seek(0) json.dump(data, f, indent=4) f.truncate()

Replace the random number generation with sequential numbering

account_number = get_next_account_number() your_username = f"openluxebuzz{account_number}"

your_birthday = "02 3 1989" #dd m yyyy exp : 24 11 2003 your_gender = "1" # 1:F 2:M 3:Not say 4:Custom your_password = "x,nscldsj123...FDKZ"

french_first_names = [ "Amélie", "Antoine", "Aurélie", "Benoît", "Camille", "Charles", "Chloé", "Claire", "Clément", "Dominique", "Élodie", "Émilie", "Étienne", "Fabien", "François", "Gabriel", "Hélène", "Henri", "Isabelle", "Jules", "Juliette", "Laurent", "Léa", "Léon", "Louise", "Lucas", "Madeleine", "Marc", "Margaux", "Marie", "Mathieu", "Nathalie", "Nicolas", "Noémie", "Olivier", "Pascal", "Philippe", "Pierre", "Raphaël", "René", "Sophie", "Stéphane", "Suzanne", "Théo", "Thomas", "Valentin", "Valérie", "Victor", "Vincent", "Yves", "Zoé", "Adèle", "Adrien", "Alexandre", "Alice", "Alix", "Anatole", "André", "Angèle", "Anne", "Baptiste", "Basile", "Bernard", "Brigitte", "Céleste", "Céline", "Christophe", "Cyril", "Denis", "Diane", "Édouard", "Éléonore", "Émile", "Félix", "Florence", "Georges", "Gérard", "Guillaume", "Hugo", "Inès", "Jacques", "Jean", "Jeanne", "Joséphine", "Julien", "Laure", "Lucie", "Maëlle", "Marcel", "Martine", "Maxime", "Michel", "Nina", "Océane", "Paul", "Perrine", "Quentin", "Romain", "Solène", "Thérèse" ]

french_last_names = [ "Leroy", "Moreau", "Bernard", "Dubois", "Durand", "Lefebvre", "Mercier", "Dupont", "Fournier", "Lambert", "Fontaine", "Rousseau", "Vincent", "Muller", "Lefèvre", "Faure", "André", "Gauthier", "Garcia", "Perrin", "Robin", "Clement", "Morin", "Nicolas", "Henry", "Roussel", "Mathieu", "Garnier", "Chevalier", "François", "Legrand", "Gérard", "Boyer", "Gautier", "Roche", "Roy", "Noel", "Meyer", "Lucas", "Gomez", "Martinez", "Caron", "Da Silva", "Lemoine", "Philippe", "Bourgeois", "Pierre", "Renard", "Girard", "Brun", "Gaillard", "Barbier", "Arnaud", "Martins", "Rodriguez", "Picard", "Roger", "Schmitt", "Colin", "Vidal", "Dupuis", "Pires", "Renaud", "Renault", "Klein", "Coulon", "Grondin", "Leclerc", "Pires", "Marchand", "Dufour", "Blanchard", "Gillet", "Chevallier", "Fernandez", "David", "Bouquet", "Gilles", "Fischer", "Roy", "Besson", "Lemoine", "Delorme", "Carpentier", "Dumas", "Marin", "Gosselin", "Mallet", "Blondel", "Adam", "Durant", "Laporte", "Boutin", "Lacombe", "Navarro", "Langlois", "Deschamps", "Schneider", "Pasquier", "Renaud" ]

Randomly select a first name and a last name

your_first_name = random.choice(french_first_names) your_last_name = random.choice(french_last_names)

your_first_name_normalized = unidecode(your_first_name).lower() your_last_name_normalized = unidecode(your_last_name).lower()

def random_delay(min_seconds=2, max_seconds=4): """Add random delay to seem more human-like""" time.sleep(random.uniform(min_seconds, max_seconds))

def fill_form(driver): try: wait = WebDriverWait(driver, 20) driver.get("https://accounts.google.com/signup/v2/createaccount?flowName=GlifWebSignIn&flowEntry=SignUp") random_delay(3, 5) # Longer initial wait

    # Fill in name fields
    first_name = wait.until(EC.presence_of_element_located((By.NAME, "firstName")))
    first_name.clear()
    first_name.send_keys(your_first_name)
    random_delay()

    last_name = wait.until(EC.presence_of_element_located((By.NAME, "lastName")))
    last_name.clear()
    last_name.send_keys(your_last_name)
    random_delay()

    next_button = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, "VfPpkd-LgbsSe")))
    next_button.click()
    random_delay(3, 5)

    # Fill in birthday
    month_dropdown = wait.until(EC.presence_of_element_located((By.ID, "month")))
    month_dropdown = Select(month_dropdown)
    birthday_elements = your_birthday.split()
    month_dropdown.select_by_value(birthday_elements[1])
    random_delay()

    day_field = wait.until(EC.presence_of_element_located((By.ID, "day")))
    day_field.clear()
    day_field.send_keys(birthday_elements[0])
    random_delay()

    year_field = wait.until(EC.presence_of_element_located((By.ID, "year")))
    year_field.clear()
    year_field.send_keys(birthday_elements[2])
    random_delay()

    # Select gender
    gender_dropdown = wait.until(EC.presence_of_element_located((By.ID, "gender")))
    gender_dropdown = Select(gender_dropdown)
    gender_dropdown.select_by_value(your_gender)
    random_delay()

    next_button = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, "VfPpkd-LgbsSe")))
    next_button.click()
    random_delay(3, 5)

    # Create custom email
    try:
        create_own_option = wait.until(EC.element_to_be_clickable((By.ID, "selectionc4")))
        create_own_option.click()
        random_delay()
    except:
        pass

    username_field = wait.until(EC.presence_of_element_located((By.NAME, "Username")))
    username_field.clear()
    username_field.send_keys(your_username)
    random_delay()

    next_button = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, "VfPpkd-LgbsSe")))
    next_button.click()
    random_delay(3, 5)

    # Enter and confirm password
    password_field = wait.until(EC.presence_of_element_located((By.NAME, "Passwd")))
    password_field.clear()
    password_field.send_keys(your_password)
    random_delay()

    confirm_passwd_div = wait.until(EC.presence_of_element_located((By.ID, "confirm-passwd")))
    password_confirmation_field = confirm_passwd_div.find_element(By.NAME, "PasswdAgain")
    password_confirmation_field.clear()
    password_confirmation_field.send_keys(your_password)
    random_delay()

    next_button = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, "VfPpkd-LgbsSe")))
    next_button.click()
    random_delay(4, 6)

    # Handle phone verification skip
    try:
        skip_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//span[contains(text(), 'Skip')]")))
        skip_button.click()
        random_delay(3, 5)
    except:
        try:
            # Alternative skip button locator
            skip_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//*[contains(@class, 'VfPpkd-vQzf8d') and contains(text(), 'Skip')]")))
            skip_button.click()
            random_delay(3, 5)
        except:
            print("Couldn't find skip button for phone verification")

    # Skip recovery email if present
    try:
        skip_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//span[contains(text(), 'Skip')]")))
        skip_button.click()
        random_delay(3, 5)
    except:
        pass

    # Agree to terms
    agree_button = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button span.VfPpkd-vQzf8d")))
    agree_button.click()
    random_delay(4, 6)

    # After successful creation, save the credentials
    save_account_credentials(your_username, your_password)

    print(f"Your Gmail successfully created:\n{{\ngmail: {your_username}@gmail.com\npassword: {your_password}\n}}")

except Exception as e:
    print("Failed to create your Gmail, Sorry")
    print(e)
finally:
    driver.quit()

Execute the function to fill out the form

fill_form(driver) `

dung13796 commented 1 day ago

I tried a mobile emulation and I couldn't get it to display a skip option.

`# Gmail Account Creation Automation Script - Version 1.1.0

Original script by Abdelhakim Khaouiti (khaouitiabdelhakim on GitHub)

Account Creation Automation Script - Version 1.1.0

Original script by Abdelhakim Khaouiti (khaouitiabdelhakim on GitHub)

from selenium import webdriver from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import Select, WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.chrome.options import Options as ChromeOptions import random import time import json import os from unidecode import unidecode

Chrome options

chrome_options = ChromeOptions() chrome_options.add_argument("--disable-infobars") chrome_options.add_argument("--disable-notifications")

Add mobile emulation

mobile_emulation = { "deviceMetrics": { "width": 360, "height": 640, "pixelRatio": 3.0 }, "userAgent": "Mozilla/5.0 (Linux; Android 10; Pixel 3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36" } chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)

Use webdriver_manager to handle ChromeDriver

driver = webdriver.Chrome( service=Service(ChromeDriverManager().install()), options=chrome_options )

def get_next_account_number(): # Create file if it doesn't exist if not os.path.exists('createdAccounts.json'): with open('createdAccounts.json', 'w') as f: json.dump({'accounts': []}, f)

# Read existing accounts
with open('createdAccounts.json', 'r') as f:
    data = json.load(f)

# Get the next number (1 if no accounts exist)
accounts = data.get('accounts', [])
next_number = len(accounts) + 1

return next_number

def save_account_credentials(username, password): with open('createdAccounts.json', 'r+') as f: data = json.load(f) data['accounts'].append({ 'email': f'{username}@gmail.com', 'password': password, 'created_at': time.strftime('%Y-%m-%d %H:%M:%S') }) f.seek(0) json.dump(data, f, indent=4) f.truncate()

Replace the random number generation with sequential numbering

account_number = get_next_account_number() your_username = f"openluxebuzz{account_number}"

your_birthday = "02 3 1989" #dd m yyyy exp : 24 11 2003 your_gender = "1" # 1:F 2:M 3:Not say 4:Custom your_password = "x,nscldsj123...FDKZ"

french_first_names = [ "Amélie", "Antoine", "Aurélie", "Benoît", "Camille", "Charles", "Chloé", "Claire", "Clément", "Dominique", "Élodie", "Émilie", "Étienne", "Fabien", "François", "Gabriel", "Hélène", "Henri", "Isabelle", "Jules", "Juliette", "Laurent", "Léa", "Léon", "Louise", "Lucas", "Madeleine", "Marc", "Margaux", "Marie", "Mathieu", "Nathalie", "Nicolas", "Noémie", "Olivier", "Pascal", "Philippe", "Pierre", "Raphaël", "René", "Sophie", "Stéphane", "Suzanne", "Théo", "Thomas", "Valentin", "Valérie", "Victor", "Vincent", "Yves", "Zoé", "Adèle", "Adrien", "Alexandre", "Alice", "Alix", "Anatole", "André", "Angèle", "Anne", "Baptiste", "Basile", "Bernard", "Brigitte", "Céleste", "Céline", "Christophe", "Cyril", "Denis", "Diane", "Édouard", "Éléonore", "Émile", "Félix", "Florence", "Georges", "Gérard", "Guillaume", "Hugo", "Inès", "Jacques", "Jean", "Jeanne", "Joséphine", "Julien", "Laure", "Lucie", "Maëlle", "Marcel", "Martine", "Maxime", "Michel", "Nina", "Océane", "Paul", "Perrine", "Quentin", "Romain", "Solène", "Thérèse" ]

french_last_names = [ "Leroy", "Moreau", "Bernard", "Dubois", "Durand", "Lefebvre", "Mercier", "Dupont", "Fournier", "Lambert", "Fontaine", "Rousseau", "Vincent", "Muller", "Lefèvre", "Faure", "André", "Gauthier", "Garcia", "Perrin", "Robin", "Clement", "Morin", "Nicolas", "Henry", "Roussel", "Mathieu", "Garnier", "Chevalier", "François", "Legrand", "Gérard", "Boyer", "Gautier", "Roche", "Roy", "Noel", "Meyer", "Lucas", "Gomez", "Martinez", "Caron", "Da Silva", "Lemoine", "Philippe", "Bourgeois", "Pierre", "Renard", "Girard", "Brun", "Gaillard", "Barbier", "Arnaud", "Martins", "Rodriguez", "Picard", "Roger", "Schmitt", "Colin", "Vidal", "Dupuis", "Pires", "Renaud", "Renault", "Klein", "Coulon", "Grondin", "Leclerc", "Pires", "Marchand", "Dufour", "Blanchard", "Gillet", "Chevallier", "Fernandez", "David", "Bouquet", "Gilles", "Fischer", "Roy", "Besson", "Lemoine", "Delorme", "Carpentier", "Dumas", "Marin", "Gosselin", "Mallet", "Blondel", "Adam", "Durant", "Laporte", "Boutin", "Lacombe", "Navarro", "Langlois", "Deschamps", "Schneider", "Pasquier", "Renaud" ]

Randomly select a first name and a last name

your_first_name = random.choice(french_first_names) your_last_name = random.choice(french_last_names)

your_first_name_normalized = unidecode(your_first_name).lower() your_last_name_normalized = unidecode(your_last_name).lower()

def random_delay(min_seconds=2, max_seconds=4): """Add random delay to seem more human-like""" time.sleep(random.uniform(min_seconds, max_seconds))

def fill_form(driver): try: wait = WebDriverWait(driver, 20) driver.get("https://accounts.google.com/signup/v2/createaccount?flowName=GlifWebSignIn&flowEntry=SignUp") random_delay(3, 5) # Longer initial wait

    # Fill in name fields
    first_name = wait.until(EC.presence_of_element_located((By.NAME, "firstName")))
    first_name.clear()
    first_name.send_keys(your_first_name)
    random_delay()

    last_name = wait.until(EC.presence_of_element_located((By.NAME, "lastName")))
    last_name.clear()
    last_name.send_keys(your_last_name)
    random_delay()

    next_button = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, "VfPpkd-LgbsSe")))
    next_button.click()
    random_delay(3, 5)

    # Fill in birthday
    month_dropdown = wait.until(EC.presence_of_element_located((By.ID, "month")))
    month_dropdown = Select(month_dropdown)
    birthday_elements = your_birthday.split()
    month_dropdown.select_by_value(birthday_elements[1])
    random_delay()

    day_field = wait.until(EC.presence_of_element_located((By.ID, "day")))
    day_field.clear()
    day_field.send_keys(birthday_elements[0])
    random_delay()

    year_field = wait.until(EC.presence_of_element_located((By.ID, "year")))
    year_field.clear()
    year_field.send_keys(birthday_elements[2])
    random_delay()

    # Select gender
    gender_dropdown = wait.until(EC.presence_of_element_located((By.ID, "gender")))
    gender_dropdown = Select(gender_dropdown)
    gender_dropdown.select_by_value(your_gender)
    random_delay()

    next_button = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, "VfPpkd-LgbsSe")))
    next_button.click()
    random_delay(3, 5)

    # Create custom email
    try:
        create_own_option = wait.until(EC.element_to_be_clickable((By.ID, "selectionc4")))
        create_own_option.click()
        random_delay()
    except:
        pass

    username_field = wait.until(EC.presence_of_element_located((By.NAME, "Username")))
    username_field.clear()
    username_field.send_keys(your_username)
    random_delay()

    next_button = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, "VfPpkd-LgbsSe")))
    next_button.click()
    random_delay(3, 5)

    # Enter and confirm password
    password_field = wait.until(EC.presence_of_element_located((By.NAME, "Passwd")))
    password_field.clear()
    password_field.send_keys(your_password)
    random_delay()

    confirm_passwd_div = wait.until(EC.presence_of_element_located((By.ID, "confirm-passwd")))
    password_confirmation_field = confirm_passwd_div.find_element(By.NAME, "PasswdAgain")
    password_confirmation_field.clear()
    password_confirmation_field.send_keys(your_password)
    random_delay()

    next_button = wait.until(EC.element_to_be_clickable((By.CLASS_NAME, "VfPpkd-LgbsSe")))
    next_button.click()
    random_delay(4, 6)

    # Handle phone verification skip
    try:
        skip_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//span[contains(text(), 'Skip')]")))
        skip_button.click()
        random_delay(3, 5)
    except:
        try:
            # Alternative skip button locator
            skip_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//*[contains(@class, 'VfPpkd-vQzf8d') and contains(text(), 'Skip')]")))
            skip_button.click()
            random_delay(3, 5)
        except:
            print("Couldn't find skip button for phone verification")

    # Skip recovery email if present
    try:
        skip_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//span[contains(text(), 'Skip')]")))
        skip_button.click()
        random_delay(3, 5)
    except:
        pass

    # Agree to terms
    agree_button = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button span.VfPpkd-vQzf8d")))
    agree_button.click()
    random_delay(4, 6)

    # After successful creation, save the credentials
    save_account_credentials(your_username, your_password)

    print(f"Your Gmail successfully created:\n{{\ngmail: {your_username}@gmail.com\npassword: {your_password}\n}}")

except Exception as e:
    print("Failed to create your Gmail, Sorry")
    print(e)
finally:
    driver.quit()

Execute the function to fill out the form

fill_form(driver) `

I tried this but i think it has no way to show skip button.