【发布时间】:2017-07-25 09:37:59
【问题描述】:
我正在尝试从 Bing 中抓取图像。我正在使用 Selenium 并尝试提取图像的源链接。
driver = webdriver.Firefox()
driver.get("http://www.bing.com/images")
elem = driver.find_element_by_id("sb_form_q")
elem.clear()
elem.send_keys("wheat zinc deficiency")
elem.send_keys(Keys.RETURN)
time.sleep(10)
driver.find_element_by_class_name("mimg").click()
driver.implicitly_wait(10)
driver.find_element_by_xpath("/html/body/div[3]/div[2]/div[1]/div/span[1]/div/div/div/div[1]/span/span/img").click()
最后一行显示错误,即
selenium.common.exceptions.NoSuchElementException: 消息:无法定位元素
我试图通过等待页面加载来避免竞争状况。 我使用firefox的firebug插件获得了xpath。
【问题讨论】:
标签: python selenium xpath selenium-firefoxdriver