首页 > 解决方案 > 如何使用 Selenium 登录全球速卖通

问题描述

我正在尝试自动登录 AliExpress.com,但找不到用户名和密码框。我在 Windows 上使用 Selenium 和 Python 3。到目前为止我已经尝试过了,这是开始:

driver = webdriver.Chrome(executable_path="C:/webdrivers/chromedriver")
driver.get('https://www.aliexpress.com')
driver.find_element_by_name("SearchText").send_keys("iphone 11")
driver.find_element_by_class_name("search-button").send_keys(Keys.ENTER)
driver.maximize_window()

继续尝试是:

find_elements_by_class_name("login-content nc-outer-box")

或者

fields = driver.find_elements_by_class_name("login-password")

或者

fields = driver.find_elements_by_class_name("fm-field")

或者

driver.find_element_by_class_name("input-plain-wrap input-wrap-loginid ").send_keys("blahblah@gmail.com")
driver.find_element_by_id("fm-login-password").send_keys("blahblah")

对于前 50 次搜索 AliExpress,让我在必须登录之前查看结果,但现在我必须登录,而且我的所有尝试都失败了,有什么想法我该怎么办?(每次我保存“字段”时,它的长度都是 0 而不是 2)

标签: pythonseleniumselenium-webdriverweb-scrapingaliexpress

解决方案


尝试以下用户名和密码字段的选择器:

用户名选择器:

driver.find_element_by_css_selector("div.input-plain-wrap.input-wrap-loginid").send_keys("blahblah@gmail.com")

或者

driver.find_element_by_css_selector("input#fm-login-id").send_keys("blahblah@gmail.com")

密码选择器:

driver.find_element_by_css_selector("div.input-plain-wrap.input-wrap-password").send_keys("password")

或者

driver.find_element_by_css_selector("input#fm-login-password").send_keys("password")

推荐阅读