(任務)
我欲利用selenium爬gmaps評論,
其中會用到selenium模擬"滾軸捲動",來加載更多評論
(遇到的問題)
當滾軸滾動至約900則評論時(已經測試多個地點評論),便無法加載下去,想問一下可能解決方案
如上圖(loading的圓圈不停的轉,等超過半小時都沒反應)
delay_choices = [4.3, 5.8, 7.2, 6, 8, 9,9.8]
delay = random.choice(delay_choices)
for i in range(141):
time.sleep(delay)
scroll_box = driver.find_element_by_css_selector('.section-scrollbox') #find scroll box
driver.execute_script('arguments[0].scrollTop = arguments[0].scrollHeight',scroll_box)#scroll to the bottom
review_text = driver.find_elements_by_class_name("ODSEW-ShBeI-text")
print(len(review_text))
(提供該部分code參考)