我知道还有一个非常类似的问题,但我的问题有点不同。
问题是,你无法使用Selenium登录Nike。它一直对我有效,但不知怎的它停止了工作。我读了一些关于如何绕过这个问题的书,找到了解决方案,只使用一个较旧的chrome版本(我使用的是chrome驱动程序)。这起到了作用,但现在已经不再是了,耐克再次阻止登录。我使用的旧版本是79。很早以前对我有效的新版本现在是最新的版本是90。
这是我试图登录Nike的代码:
import time
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--disable-blink-features")
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36")
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options = chrome_options)
driver.get("https://www.nike.com/login")
time.sleep(2)
email = driver.find_element_by_xpath('//input[@type="email"]')
email.send_keys("THE-EMAIL")
password = driver.find_element_by_xpath('//input[@type="password"]')
password.send_keys("THE-PASSWORD")
button = driver.find_element_by_xpath("/html/body/div[2]/div[3]/div[7]/form/div[6]/input")
button.click()
有人知道这是为什么吗?我的意思是我可以手动登录,所以这不是因为帐户。