【发布时间】:2021-08-12 13:21:12
【问题描述】:
我正在尝试抓取 google maps 评论,但是当我尝试实现滚动部分时,selenium 会抛出错误。
这是我的代码
def __scroll(self):
scrollable_div = self.driver.find_element_by_css_selector('div.section-layout.section-scrollbox.scrollable-y.scrollable-show')
self.driver.execute_script('arguments[0].scrollTop = arguments[0].scrollHeight', scrollable_div)
这只是滚动部分,这里 selenium 抛出错误
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"div.section-layout.section-scrollbox.mapsConsumerUiCommonScrollable__scrollable-y.mapsConsumerUiCommonScrollable__scrollable-show"}
(Session info: headless chrome=90.0.4430.212)
我在 github 上尝试了其他建议,但没有奏效。任何想法我如何实现这部分?
【问题讨论】:
-
能否提供网页链接?
-
selector":"div.section-layout.section-scrollbox.mapsConsumerUiCommonScrollable__scrollable-y.mapsConsumerUiCommonScrollable__scrollable-show遇到异常,请分享相关代码。 -
这是一个示例网址:google.com/maps/place/El+TabanKo/@42.848117,-2.6741402,19z/…@Prophet
-
但它基本上几乎所有的谷歌地图地方评论
标签: python-3.x selenium google-maps web-scraping css-selectors