【发布时间】:2021-10-28 13:00:20
【问题描述】:
我是 python 新手。我试图通过提供用户名和密码来提取https://live-cosmos.finq.com/trading-platform/?path=details&symbol=SILVER#login 上的数据。有用。 但是当尝试点击另一个按钮时它不起作用。 (“存款”或“X”关闭)
存款元素的 HTML:
<button class="btn btn-primary">Deposit</button>
存款元素的快照:
我的代码是
from selenium import webdriver
import time
driver = webdriver.Chrome(executable_path="C:\\Chromedriver\\Chromedriver.exe")
driver.maximize_window();
driver.get('https://live-cosmos.finq.com/trading-platform/?path=details&symbol=SILVER#login')
time.sleep(5)
driver.find_element_by_xpath("/html/body/div[2]/div[4]/div[2]/div/div/div/div/div/div/form/div/div[3]/div[1]/input").send_keys("username@gmail.com")
driver.find_element_by_xpath("/html/body/div[2]/div[4]/div[2]/div/div/div/div/div/div/form/div/div[3]/div[2]/input").send_keys("password_here")
driver.find_element_by_xpath("/html/body/div[2]/div[4]/div[2]/div/div/div/div/div/div/form/div/div[3]/button").click()
time.sleep(20) # wait for loading
driver.find_element_by_xpath("/html/body/div[8]/div/div/div/div/div[3]/div[1]/div[4]/button").click()
输出是
<bound method WebElement.click of <selenium.webdriver.remote.webelement.WebElement (session="28205c2be15699403ddfcc3f3ce2fa33", element="03ae577c-b3d4-423c-b7ed-1d9c5ea3ea1a")>>
您能否帮我解决这个问题(或其他方法)并继续从网站上抓取一些文本。 提前谢谢你。
【问题讨论】:
-
添加您尝试点击的元素的相关 HTML。
-
不是元素的截图,而是元素的相关HTML。
标签: python selenium selenium-webdriver xpath webdriverwait