Skip to content
Advertisement

Scroll down google reviews with selenium

I’m trying to scrape the reviews from this link:

https://www.google.com/search?q=google+reviews+2nd+chance+treatment+40th+street&rlz=1C1JZAP_enUS697US697&oq=google+reviews+2nd+chance+treatment+40th+street&aqs=chrome..69i57j69i64.6183j0j7&sourceid=chrome&ie=UTF-8#lrd=0x872b7179b68e33d5:0x24b5517d86a95f89,1

For what I’m using the following code to load the page

JavaScript

The page load fine, it is not scrolling down, I have used the same code for other sites like linkedn and it works there.

Advertisement

Answer

Here is the logic that you can use without using the javascript scroll down. Simple and effective by using the location_once_scrolled_into_view method which will scroll to the element.

As part of logic below, we are scrolling to the last review, and then checking if we loaded the number of reviews desired as per the request.

Imports Needed:

JavaScript

change the desiredReviewsCount variable value as per your requirement in the below code.

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement