Я зашел в Google и ChatGPT, и он выплюнул мне это
Код: Выделить всё
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
import time
# Path to Brave Browser executable
brave_path = "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
# Path to ChromeDriver (if moved to /usr/local/bin, no need for full path)
chromedriver_path = "/usr/local/bin/chromedriver"
# Configure Selenium to use Brave
options = webdriver.ChromeOptions()
options.binary_location = brave_path
# Start WebDriver with Brave
driver = webdriver.Chrome(service=Service(chromedriver_path), options=options)
# Open WhatsApp Web
driver.get("https://web.whatsapp.com")
# Wait for login
input("Log in to WhatsApp Web and press Enter...")
# Example: Print the page title
print("Page title is:", driver.title)
# Wait for the search box to be available
wait = WebDriverWait(driver, 30) # Wait for up to 30 seconds
search_box = wait.until(EC.presence_of_element_located((By.XPATH, '//div[@contenteditable="true"][@data-tab="3"]')))
# Click on the search box and type the chat name
search_box.click()
search_box.send_keys("Group Name") # Replace with your group's name
search_box.send_keys(Keys.ENTER)
# Wait for the message box to be both present and visible
message_box = wait.until(EC.visibility_of_element_located((By.XPATH, '//div[@contenteditable="true"][@data-tab="1"]')))
time.sleep(2) # Optional: Add delay to ensure the message box is ready
# Initialize ActionChains
actions = ActionChains(driver)
# Send "@John" 100 times in the message box
for _ in range(100):
actions.move_to_element(message_box).click().send_keys("@John").perform()
actions.send_keys(Keys.SHIFT + Keys.ENTER).perform() # To create a new line without sending
# Finally, send the message
actions.send_keys(Keys.ENTER).perform()
# Close browser
driver.quit()
также я настроил Chrome и все остальное на своем компьютере, смог войти в систему и правильно перейти к групповому чату
просто скрипт не писал его имя 100 раз и не отправлял это ему
также было бы очень полезно, если бы сценарий пометил его 100 раз, если это возможно.
также мы собирались играть в CS-Go
Просто ради интереса, если кто-то здесь скрывается, поделитесь помощью.
Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/791 ... pp-desktop