- Привет всем. Я пытаюсь создать программу на Python, которая будет отправлять цикл сообщений получателю, используя мою собственную голосовую учетную запись Google. программа работает следующим образом:
введите имя пользователя, подождите
введите пароль, затем подождите
номер получателей ввода
ввод текста
отправка
цикл из введенного текста
программа работает до тех пор, пока не пройдет ввод имени пользователя. это должен быть ввод имени пользователя, а затем ввод пароля. однако после того, как он вводит имя пользователя и нажимает Enter, появляется обнаружение ботов Crome и сообщает: «Браузер, возможно, небезопасен», а затем появляется кнопка «Повторить попытку». у меня есть в коде попытка действовать более человечно, как определения. я не думаю, что они работают так, как задумано (они не взломали код), но любая помощь в этом будет очень признательна.
моя главная цель — обойти обнаружение ботов. я знаю, что это будет нелегко. Я очень новичок в программировании и в том, что я могу сделать. вот мой код
import threading
import time
import random
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# Global variable for the kill switch
kill_switch = False
# Function to listen for key press (kill switch)
def listen_for_kill_switch():
global kill_switch
while not kill_switch:
user_input = input("Press '1' to stop the program: ")
if user_input == '1':
kill_switch = True
print("Kill switch activated! Stopping the program.")
# Path to ChromeDriver (update this to the correct path on your machine)
chrome_driver_path = "C:\webdrivers\chromedriver.exe" # Update this path
# Set up Chrome options to disable automation detection
chrome_options = Options()
chrome_options.add_argument("--disable-blink-features=AutomationControlled") # Hide automation
chrome_options.add_argument("--disable-infobars") # Remove info bar showing automation control
chrome_options.add_argument("--start-maximized") # Start maximized
#chrome_options.add_argument("--incognito") # Optionally use incognito mode
# Optionally, add a custom user-agent to mimic a real browser
user_agents = [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36"
]
chrome_options.add_argument(f"user-agent={random.choice(user_agents)}") # Random user-agent
# Set up the WebDriver
service = Service(chrome_driver_path)
driver = webdriver.Chrome(service=service, options=chrome_options)
# Start the key press listener in a separate thread
listener_thread = threading.Thread(target=listen_for_kill_switch)
listener_thread.start()
try:
# Navigate to Google login page
driver.get("https://accounts.google.com/v3/signin/identifier? continue=https%3A%2F%2Fvoice.google.com%2Fsignup&followup=https%3A%2F%2Fvoice.google.com%2Fsignup&osid=1&passive=1209600&service=grandcentral&ifkv=AcMMx-foRSvj9aaIkGme-TbLDTEgcVhogjRFWAk2Mtz4tM9eJGMMgIDDRhgXCdo8NvkgQ9b_bhoz&ddm=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin%22)")
# Simulate some human-like delay
time.sleep(random.uniform(2, 4)) # Random delay between 2 and 4 seconds
# Automate the email input with human-like delay
email_input = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "identifierId"))
)
for character in "myemail@gmail.com": # Replace with your email
email_input.send_keys(character)
time.sleep(random.uniform(0.1, 0.3)) # Random delay between keystrokes
email_input.send_keys(Keys.RETURN)
# Simulate a delay for password input
time.sleep(random.uniform(2, 5))
password_input = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.NAME, "password"))
)
for character in "your-password": # Replace with your password
password_input.send_keys(character)
time.sleep(random.uniform(0.1, 0.3)) # Random delay
password_input.send_keys(Keys.RETURN)
# Wait for the login process to complete
time.sleep(random.uniform(4, 6))
# Continue with further actions (e.g., sending a message, etc.)
driver.get("https://voice.google.com")
# Simulate a pause before interacting with the page
time.sleep(random.uniform(4, 6))
# Wait for the "Send a message" button to be clickable and click it
send_message_button = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, "div[aria-label='Send a message']"))
)
send_message_button.click()
# Define the recipient's phone number and the list of messages
phone_number = "1234567890" # Replace with the recipient's phone number
messages = [
"Hello, this is message 1.",
"This is message 2.",
"Another test message, number 3.",
"Final message, number 4!"
]
# Loop through the list of messages and send each one, checking the kill switch
for message_text in messages:
if kill_switch:
print("Kill switch detected! Exiting the loop.")
break
# Check for the phone number input field and enter the phone number
phone_input = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, "input[type='tel']"))
)
phone_input.clear() # Clear the input field
phone_input.send_keys(phone_number)
# Check for the message input field and enter the message text
message_input = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, "textarea[aria-label='Message']"))
)
message_input.clear() # Clear the input field
message_input.send_keys(message_text)
# Send the message by simulating pressing Enter
message_input.send_keys(Keys.RETURN)
print(f"Sent: {message_text}")
# Wait a few seconds before sending the next message to avoid being flagged as spam
time.sleep(random.uniform(4, 6)) # Adjust the delay as needed
print("Program completed or stopped by kill switch.")
except Exception as e:
# Handle exceptions by printing the error message
print(f"An error occurred: {e}")
finally:
# Make sure to close the browser window
driver.quit()
print("Browser closed. Program exited.")
Подробнее здесь: https://stackoverflow.com/questions/791 ... -detection
Мобильная версия