Wpis z mikrobloga

#programowanie #pytanie

hej, jestem całkowicie zielona a chciałabym sobie hobbistycznie napisać na początku bota na sympatię (wyszukiwanie nowych użytkowników po ikonce zielonego listka, spisywanie linku do ich profilu do pliku txt, wysyłanie im wiadomości [a w sumie jednej osobie jednej wiadomości dziennie]), a potem scrapera ekw xD

narazie się zatrzymałam na niemożności przejściu do danej podstrony (meet) na sympatii :( coś po zalogowaniu nie mogę na nią wejść :( chatgpt nie daje rady pomóc

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

# Initialize the Chrome web driver
driver = webdriver.Chrome()

# Open a website
driver.get("[https://login.sympatia.onet.pl](https://login.sympatia.onet.pl)") # Replace with the URL of the website you want to visit

# Wait for the cookie banner to appear (customize the selector and timeout)
try:
cookie_banner = WebDriverWait(driver, 5).until(
EC.presence_of_element_located((By.XPATH, "//*[@id='rasp_cmp']/div")) # Replace with the actual element ID or selector
)

# Accept the cookies (customize the button selector)
accept_button = cookie_banner.find_element(By.XPATH, "//*[@id='rasp_cmp']/div/div[6]/button[2]") # Replace with the actual button ID or selector
accept_button.click()
except Exception as e:
print("Could not find or click the accept button:", str(e))

username = driver.find_element(By.NAME, 'email')
password = driver.find_element(By.NAME, 'password')

username.send_keys("aaa")
password.send_keys("bbb")

# Submit the form

driver.find_element(By.XPATH,'//*[@id="__next"]/div[1]/div[1]/div/form/button').click()

# Continue with your interactions on the logged-in website
# ...

wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="menuContainer"]/div/div[2]/nav/ul/li[2]/a/div[2]')))

#desired_page_url = "[https://sympatia.onet.pl/meet"](https://sympatia.onet.pl/meet")
#driver.get(desired_page_url)

# Define the XPath of the element you want to click
#xpath = "//*[@id='menuContainer']/div/div[2]/nav/ul/li[2]/a/div[2]"

# Find the element using its XPath
#element = driver.find_element_by_xpath(xpath)

# Click the element
#element.click()
  • 7