我很难从下拉列表中选择(实际上有两个,季节和日期)。我可以获得我想输入到下拉选择器的值,但是我无法理解我需要做什么才能从下拉列表中编程选择
下面是我正在使用的基本代码:(非常抱歉格式化,长字符串有问题。)
`import requests
from selenium import webdriver
from time import sleep
from bs4 import BeautifulSoup
url='https://dataride.uci.ch/iframe/RankingDetails/1?disciplineId=10&groupId=1&momentId=19264&disciplineSeasonId=19&rankingTypeId=1&categoryId=22&raceTypeId=0' browser=webdriver.Chrome(executable_path='F:\Anaconda\chromedriver\chromedriver_win32\chromedriver.exe')
browser.get(url) season_list=browser.find_element_by_id('seasons_listbox').get_attribute('textContent')dates_list=browser.find_element_by_id('dates_listbox').get_attribute('textContent').split('Ranking')[1]
for i in range(0,len(season_list),4):
year=season_list[i:i+4]
for j in range(0,len(dates_list),10):
date=dates_list[j:j+10]
print('YEAR: ',season_list[i:i+4],' DATE ',dates_list[j:j+10])`
这是工作代码。我使用
xpath
获得下拉菜单,然后使用send_keys
如果您想从下拉列表中选择
option
,那么您需要获得整个列表相关问题 更多 >
编程相关推荐