我想写一个脚本来自动登录到ebay使用python中的硒模块。脚本自动登录到ebay使用硒python
我可以在Firefox中启动登录页面。这里的代码:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['binary'] = '/usr/bin/firefox'
driver = webdriver.Firefox(capabilities=firefox_capabilities)
driver.get("https://signin.ebay.in/ws/eBayISAPI.dll?SignIn&ru=http%3A%2F%2Fwww.ebay.in%2F")
search_field = driver.find_element("Email or username")
search_field.clear()
search_field.send_keys("My username")
但这似乎不工作。我不能使用
3210因为id保持动态变化。
<input size="40" maxlength="64" name="147630419" id="147630419" autocapitalize="off" autocorrect="off" placeholder="Email or username" class="fld" type="text">
这就是电子邮件占位符的样子。密码的占位符也类似。 “名称”和“ID”动态变化。
我该如何解决这个问题?
尝试的XPath' “” 提出了一个(//输入[@ placeholder ='Email or username'])[2]“' –