相关疑难解决方法(0)

Selenium无法定位元素(Python)WebScraping

我正试图抓住一个房地产网站上市.它有一个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)
Run Code Online (Sandbox Code Playgroud)

当我运行这个脚本时,它会给出一个错误"找不到元素"ForSalePropertyType".我在这里做错了什么?提前谢谢.

python selenium web-scraping selenium-webdriver

4
推荐指数
1
解决办法
440
查看次数