问题
if soyunmaDolabi < 3:
from selenium import webdriver
import time
browser = webdriver.Chrome(r"C:\Users\Dell\Desktop\lol/chromedriver.exe")
browser.get("https://sahibinden.com")
popUp = browser.find_element_by_xpath("//*[@id='container']/div[3]/div/aside/div[1]/nav/ul[2]/li[1]")
LogIn= browser.find_element_by_xpath("/html/body/div[3]/div[1]/ul/li[1]/a")
time.sleep(2)
popUp.click()
time.sleep(2)
LogIn.click()
kadi = browser.find_element_by_xpath("//*[@id='username']")
password = browser.find_element_by_xpath("//*[@id='password']")
LogInButton= browser.find_element_by_xpath("//*[@id='userLoginSubmitButton']")
kadi.send_keys("cemal_1264@hotmail.com")
password.send_keys("asdasd")
LogInButton.click()
time.sleep(200)
browser.close()
Hi there, i want to login automatic sahibinden.com. Then i wrote this code. Code is working, code is clicking the login button but website does not login. But when i click the button manual it does work.
what should i do
https://prnt.sc/qvnhza https://prnt.sc/qvnhmw
回答1:
This code works, you can edit this as per your need:
from selenium.webdriver import Chrome
browser = Chrome()
browser.get("https://secure.sahibinden.com/giris")
email = browser.find_element_by_id("username")
password = browser.find_element_by_id("password")
login = browser.find_element_by_id("userLoginSubmitButton")
email.send_keys("myemail")
password.send_keys("mypassword")
login.click()
Also avoid using xpath because it is not stable.
来源:https://stackoverflow.com/questions/60006165/how-can-i-auto-login-sahibinden-com