python - 如何使用 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)
解决方案
尝试以下用户名和密码字段的选择器:
用户名选择器:
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")
推荐阅读
- typescript - 如何通过悬停文档选择器找出定义?帮我 :)
- css - 为什么 flexbox 中的宽高比 CSS 属性有时会被忽略?
- angular - 根据先前的选择值显示选择选项
- c++ - FindFirstFile() 在几个循环后为现有文件夹返回 ERROR_PATH_NOT_FOUND
- typescript - Typescript - AWS CDK 启用 CORS
- linux - 如何为 Raspberry Pi 3 制作更新映像
- node.js - Node Js 从 mongoose 集合返回 null
- c# - 从 ASP.net Core (v2.1) WebAPI 中的 JSON 文件读取记录
- angular - 多列上的 Angular Slickgrid 过滤
- react-native - 是否可以在 react-native-searchable-dropdown 中添加新值?