【发布时间】:2020-01-01 11:48:38
【问题描述】:
我在抓取使用 react.js 的网站时遇到了一些困难,但不知道为什么会这样。
我想做的是单击带有class: play-pause-button btn btn -naked 的按钮。但是,当我使用 Mozilla gecko webdriver 加载页面时,会抛出一个异常,说
Message: Unable to locate element: .play-pause-button btn btn-naked
这让我觉得也许我应该做点别的来获得这个元素? 到目前为止,这是我的代码:
driver.get("https://drawittoknowit.com/course/neurological-system/anatomy/peripheral-nervous-system/1332/brachial-plexus---essentials")
# execute script to scroll down the page
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);var lenOfPage=document.body.scrollHeight;return lenOfPage;")
time.sleep(10)
soup = BeautifulSoup(driver.page_source, 'lxml')
print(driver.page_source)
play_button = driver.find_element_by_class_name("play-pause-button btn btn-naked").click()
print(play_button)
有人知道我该如何解决这个问题吗?非常感谢任何帮助
【问题讨论】:
标签: python reactjs selenium web-scraping webdriverwait