我正在尝试提取仅在 JavaScript 运行后创建的元素,但我不断收到以下错误消息:
selenium.common.exceptions.NoSuchElementException: Message: u'Unable to locate element: {"method":"id","selector":"post-count"}' ; Stacktrace: Method FirefoxDriver.prototype.findElementInternal_ threw an error in file:///tmp/tmpittNsw/extensions/fxdriver@googlecode.com/components/driver_component.js
我正在尝试在 cnn.com 上提取此元素。我的代码:
socket.setdefaulttimeout(30)
browser = webdriver.Firefox() # Get local session of firefox
browser.get(article_url_txt) # Load page
result = browser.find_element_by_id("post-count")