Python ommon.exceptions.NoSuchElementException:消息:没有这样的元素:无法定位元素:{method:xpath,selector://select[id='msku-sel-1']/option[1]}先生,您好,基本上您的

Python ommon.exceptions.NoSuchElementException:消息:没有这样的元素:无法定位元素:{method:xpath,selector://select[id='msku-sel-1']/option[1]}先生,您好,基本上您的,python,selenium,selenium-webdriver,web-scraping,Python,Selenium,Selenium Webdriver,Web Scraping,ommon.exceptions.NoSuchElementException:消息:没有这样的元素:无法定位元素:{method:xpath,selector://select[id='msku-sel-1']/option[1]}先生,您好,基本上您的代码只是打印出所有下拉列表。我需要通过所有下拉列表,打印出选项/选项+价格,例如使用此链接尝试您的代码-。我的代码向您展示了如何循环所有选项,然后您需要提取相关信息 number_of_dropdowns = len(WebDriverWai


ommon.exceptions.NoSuchElementException:消息:没有这样的元素:无法定位元素:{method:xpath,selector://select[id='msku-sel-1']/option[1]}先生,您好,基本上您的代码只是打印出所有下拉列表。我需要通过所有下拉列表,打印出选项/选项+价格,例如使用此链接尝试您的代码-。我的代码向您展示了如何循环所有选项,然后您需要提取相关信息
number_of_dropdowns =  len(WebDriverWait(driver,10).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "[id^='msku-sel-']"))))

for i in range(1, number_of_dropdowns + 1):
    current_dropdown = driver.find_element_by_css_selector("[id^='msku-sel-" + str(i) + "']")
    #then use usual syntax to work with select 
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.select import Select

urls = ['https://www.ebay.co.uk/itm/Pashmina-Scarf-100-Viscose-Plain-Wrap-Shawl-Stole-Scarf-Many-Colours-Available/252342060680']
d = webdriver.Chrome()

for url in urls:
    d.get(url)
    number_of_dropdowns =  len(WebDriverWait(d,10).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, "[id^='msku-sel-']"))))

    for i in range(1, number_of_dropdowns + 1):
        #then use usual syntax to work with select 
        select = Select(d.find_element_by_css_selector("[id^='msku-sel-" + str(i) + "']"))
        options = select.options
        for index in range(1, len(options) - 1): #avoid first index
            select.select_by_index(index)
            #print(select.first_selected_option.text)
            #your code to extract info per option goes here