0

尝试为全功能图表导出图表数据,但 selenium 在到达图表时会抛出此豁免。请帮忙谢谢。

selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法找到元素:{“method”:“css selector”,“selector”:“.button-9U4gleap button-2ioYhFEY apply-common-tooltip isInteractive-20uLObIc” (会话信息:铬=83.0.4103.116)

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
import time
import re
import pyautogui

PATH = "/Applications/chromedriver"
driver = webdriver.Chrome(PATH)
driver.get("https://www.tradingview.com/chart/GZ2VoO8U/#signin")

# Sign into the page

time.sleep(2)
username = 
password = 
driver.find_element_by_xpath('//*[@id="overlap-manager-root"]/div/div[2]/div/div/div/div/div/div[1]/div[5]/div/div[1]/div/span').click()
driver.find_element_by_name('username').send_keys(username)
driver.find_element_by_name('password').send_keys(password)
driver.find_element_by_class_name('tv-button__loader').click()
time.sleep(10)  # ensure the page loads (bottleneck)

#Search for the currency pair
driver.find_element_by_name("query").send_keys("AUDUSD", Keys.RETURN)

time.sleep(2)

#Gets the full size chart of the pair
driver.find_element_by_xpath('//*[@id="js-category-content"]/div/div/div/div/div[1]/div/div[1]/div/a').click()

time.sleep(10)

driver.find_element_by_class_name("button-9U4gleap button-2ioYhFEY apply-common-tooltip isInteractive-20uLObIc").click()

driver.find_element_by_xpath('//*[@id="overlap-manager-root"]/div/span/div[1]/div/div/div[5]/div').click()

driver.find_element_by_xpath('//*[@id="overlap-manager-root"]/div/div/div[1]/div/div[2]/div/div[3]/div[2]/div').click()

driver.find_element_by_xpath('//*[@id="overlap-manager-root"]/div/div/div[2]/div/span/div[1]/div/div/div[1]').click()

driver.find_element_by_xpath('//*[@id="overlap-manager-root"]/div/div/div[1]/div/div[3]/div/span/button').click()
4

0 回答 0