i want to iterate through this carousel at the top of gog.com. it advertises games for sale. i want to iterate through each slide of the carousel and get the price of each. I took 2 xpaths for prices of different games.
/html/body/div[2]/div/div[3]/div/div[3]/div[2]/div/a[4]/div[2]/div/div/div[3]/div/span/span
/html/body/div[2]/div/div[3]/div/div[3]/div[2]/div/a[10]/div[2]/div/div/div[3]/div/span/span
i figure i could just iterate through the a tags like
for i in range(15):
i+=1;
A = "/html/body/div[2]/div/div[3]/div/div[3]/div[2]/div/a["+str(i)+"]/div[2]/div/div/div[3]/div/span[2]/span"
try:
print(driver.find_elements_by_xpath(A));
but i cant get it to print the price.
bellow is my full script
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r"../Downloads/chromedriver.exe")
driver.get('https://www.gog.com/')
driver.maximize_window()
WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,"/html/body/div[2]/div/div[3]/div/div[3]/div[2]/div/a[10]/div[2]/div/div/div[3]/div/span/span")))
for i in range(15):
i+=1;
A = "/html/body/div[2]/div/div[3]/div/div[3]/div[2]/div/a["+str(i)+"]/div[2]/div/div/div[3]/div/span[2]/span"
try:
print(driver.find_elements_by_xpath(A));
print(driver.find_elements_by_xpath(A).text);
print(str(driver.find_elements_by_xpath(A)));
finally:
pass