使用Selenium& Scraping刮削动态数据Python'无法找到元素'

时间:2017-06-16 10:02:37

标签: python selenium webdriver

我试图使用Selenium&用来抓取网站的Python(http://epl.squawka.com/english-premier-league/06-03-2017/west-ham-vs-chelsea/matches)。我正在使用webdriver来单击标题,然后等待新信息加载,然后再单击一个对象,然后再抓取结果数据(通过单击加载)。我的问题是我继续得到一个“无法找到元素错误”。

此时我已经截取屏幕截图并且可以实际看到该元素,并且我还打印了整个源代码,并且可以看到元素在那里。

driver.find_element_by_id("mc-stat-shot").click()
time.sleep(3)
driver.save_screenshot('test.png')
try:
    element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID,"svg")))
finally:
    driver.find_element_by_xpath("//g[3]/circle").click()
time.sleep(1)
goalSource = driver.page_source
goalBsObj = BeautifulSoup(goalSource, "html.parser")
#print(goalBsObj)
print(goalBsObj.find(id="tt-mins").get_text())
print(goalBsObj.find(id="tt-event").get_text())
print(goalBsObj.find(id="tt-playerA").get_text())

,结果是错误: " selenium.common.exceptions.NoSuchElementException:消息:无法找到element:// g [3] / circle"

0 个答案:

没有答案