【发布时间】:2020-10-18 22:31:44
【问题描述】:
我正在尝试从网页中提取数据,其中下拉列表中的选项是根据我们的输入动态加载的。我正在使用 Selenium Webdriver 从下拉列表中提取数据。请看下面的截图。
在我选择州后加载城市下拉选项,在我选择城市后加载车站下拉选项。
到目前为止,我能够使用此代码提取电台名称。
citiesList = []
stationNameList = []
siteIdList = []
for city in cityOptions[1:]:
citiesList.append(city.text)
stationDropDown = driver.find_element_by_xpath("//select[contains(@id,'stations')]")
stationOptions = stationDropDown.find_elements_by_tag_name('option')
for ele in citiesList:
cityDropdown.send_keys(ele, Keys.RETURN)
time.sleep(2)
stationDropDown.click()
print(stationDropDown.text)
Option values from station dropdown
谁能帮我提取每个州和城市的siteId?
【问题讨论】:
-
请提供网址?
-
网站上只有站点站点 ID。你想只废弃那个还是其他的?
-
站台 ID 和站名。
标签: python selenium web-scraping webdriver