我想在一个房地产网站上搜索房源。它有一个必须在提交前填写的aspx表格。在
http://www.cbre.us/PropertyListings/Pages/Properties-for-Sale.aspx
不过,我关心的是俄勒冈州的多户型房产。所以这是我的第一次尝试:
driver = webdriver.Firefox()
driver.get("http://www.cbre.us/PropertyListings/Pages/Properties-for-Sale.aspx")
#Searching for multifamily residences
selectPropertyType = driver.find_element_by_id("ForSalePropertyType")
selectPropertyType.select_by_value("70")
#In the state of Oregon
selectState = driver.find_element_by_id("ForSaleState_ListBox1")
selectState.select_by_value("OR")
#Submit form
submitBtn = driver.find_element_by_id("ForSaleLooplinkSubmit")
submitBtn.click()
#Wait for results to load
WebDriverWait(driver, 5)
当我运行这个脚本时,它会给出一个错误“cannotlocate element”ForSalePropertyType。我做错什么了?提前谢谢。在
此元素位于
iframe
内。你必须切换到它的上下文:要返回默认上下文:
^{pr2}$另外,请注意Disclaimer / Terms of use中列出的策略,特别是:
相关问题 更多 >
编程相关推荐