Is there anyone can help me?
I want to track live stock price, using Selenium.
That's my code:
#https://www.youtube.com/watch?v=CtCeuJaRgLQ&t=16s&ab_channel=GüneyBircan
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(options=options)
driver.maximize_window()
driver.delete_all_cookies()
driver.get("https://finans.mynet.com/borsa/hisseler/asels-aselsan/")
driver.implicitly_wait(5)
price_info = driver.find_element(By.XPATH('/html/body/section/div[1]/div[1]/div[3]/div/div[1]/div[1]/div[2]/div[1]/div'))
Exception:
price_info = driver.find_element(By.XPATH('/html/body/section/div[1]/div[1]/div[3]/div/div[1]/div[1]/div[2]/div[1]/div')) TypeError: 'str' object is not callable PS C:\Users\Lenovo\Desktop\Akademi\AlgoTrading\yfinance>
CodePudding user response:
Use
price_info = driver.find_element(By.XPATH, '/html/body/section/div[1]/div[1]/div[3]/div/div[1]/div[1]/div[2]/div[1]/div')
Instead of
price_info = driver.find_element(By.XPATH('/html/body/section/div[1]/div[1]/div[3]/div/div[1]/div[1]/div[2]/div[1]/div'))