Open victorviro opened 12 months ago
This is due to the changing of the language of the driver is not working
Adding this line chrome_options.add_experimental_option('prefs', {'intl.accept_languages': lang})
solves the problem
Anyway, I recommend use the english language. Otherwise logins may not be found https://github.com/bstoilov/py3-pinterest/blob/8a01d433f4b87148b384d2389d6a5c26263e2337/py3pin/Pinterest.py#L212 due to the text to search may be different
Running into the same issue I can confirm that changing the profile settings on Pinterest to country: US and language English solves this problem but will of course change your user experience in Pinterest to English. Hence I tried something different and change the login function in Pinterest.py to:
...
driver = webdriver.Chrome(options=chrome_options)
# select login url according to lang parameter
login_url = "https://pinterest.com/login"
if lang == "de":
login_url = "https://pinterest.de/login"
driver.get(login_url)
try:
WebDriverWait(driver, wait_time).until(
EC.element_to_be_clickable((By.ID, "email"))
)
driver.find_element(by = By.ID, value='email').send_keys(self.email)
driver.find_element(by = By.ID, value="password").send_keys(self.password)
driver.find_element(by = By.ID, value="password").send_keys(Keys.ENTER)
WebDriverWait(driver, wait_time).until(
EC.invisibility_of_element((By.ID, "email"))
)
cookies = driver.get_cookies()
...
It is important to use the language specific login page, seems Pinterest does some magic in conjunction with the language setting in the profile. To be more independent from language specific web page content, instead of searching the element to click on the web-page, you can just send a key press for the return key.
This solution works for me using English or German and probably will work for other languages too, if you extend the if-clause determin the login_url.
I specify the language when login:
pinterest.login(lang="en")
. But when driver goes to "https://pinterest.com/login" https://github.com/bstoilov/py3-pinterest/blob/8a01d433f4b87148b384d2389d6a5c26263e2337/py3pin/Pinterest.py#L202 it redirects automatically to spanish version "https://www.pinterest.es/login/"Then the login fails at looking for logins https://github.com/bstoilov/py3-pinterest/blob/8a01d433f4b87148b384d2389d6a5c26263e2337/py3pin/Pinterest.py#L212 since the text to search is different ("Iniciar sesión" instead of "Log in")