【发布时间】:2019-08-29 07:42:39
【问题描述】:
我是 python 网络抓取和尝试自动化网站的初学者。在我要抓取的网站中有一个搜索过滤器,我在输入框下拉标签上应用过滤器。
在下拉框中,我写下了国家名称,所有国家都相应地出现,但我无法选择或单击下拉框中作为值出现的第一个国家。我也应用了一些代码,但我的脚本失败并终止。
下图是为了更好的理解。
enter image description here
我也应用了一些代码,请在下面查看
p_location='united states'
browser.find_by_xpath("//label[contains(.,'Geography')]").first.click()
actions_wait_time = randint(15, 30)
time.sleep(actions_wait_time)
loc_input = browser.find_by_xpath("//input[@placeholder='Add locations']")
loc_input.type(p_location)
actions_wait_time = randint(15, 30)
time.sleep(actions_wait_time)
loc_input.type(Keys.TAB)
time.sleep(3)
loc_input.type(Keys.RETURN)
我想从下拉列表中选择第一个值。请帮忙
【问题讨论】:
-
你能提供网址吗?或者至少,通过edit 使用提供的sn-p 工具的html。还请包括您遇到的错误的当前堆栈跟踪。
标签: python selenium-webdriver web-scraping splinter