Google maps pagination, can't scrape page 2

Hi there! :slight_smile:

I'm facing a problem scraping google maps.

I can scrape the first 20 elements, then I can move to the second page and open the 21st element but at this point the scraper end.

I can't really figure out what I'm doing wrong. It should keep scraping. Can anyone take a look and tell me what I'm doing wrong?

The "next" button in google maps is selected with button[aria-label="Pagina successiva"]. This is "next page" in Italian. You probably need to replace it for it to work in your language.

Thanks in advance!

Url: https://www.google.com/maps/search/?q=agenzia+pubblicitĂ +milano

Sitemap:
{"_id":"googlemaps","startUrl":["https://www.google.com/maps/search/?q=agenzia+pubblicitĂ +milano"],"selectors":[{"id":"activity","type":"SelectorElementClick","parentSelectors":["_root","nextpage"],"selector":"div.widget-pane-content","multiple":true,"delay":"1000","clickElementSelector":"h3.section-result-title span","clickType":"clickOnce","discardInitialElements":"do-not-discard","clickElementUniquenessType":"uniqueText"},{"id":"shop_name","type":"SelectorText","parentSelectors":["activity"],"selector":"h1.section-hero-header-title","multiple":false,"regex":"","delay":"2000"},{"id":"address","type":"SelectorText","parentSelectors":["activity"],"selector":"[data-section-id='ad'] span.widget-pane-link","multiple":false,"regex":"","delay":"2000"},{"id":"mobile_no","type":"SelectorText","parentSelectors":["activity"],"selector":"div.section-info-action-button.section-info-speak-numeral span.widget-pane-link","multiple":false,"regex":"","delay":"2000"},{"id":"website","type":"SelectorText","parentSelectors":["activity"],"selector":".section-info-underline span.widget-pane-link","multiple":false,"regex":"","delay":0},{"id":"pluscode","type":"SelectorText","parentSelectors":["activity"],"selector":"[data-section-id='ol'] span.widget-pane-link","multiple":false,"regex":"","delay":0},{"id":"nextpage","type":"SelectorElementClick","parentSelectors":["_root","nextpage"],"selector":"div[data-result-index]","multiple":false,"delay":"1000","clickElementSelector":"button[aria-label="Pagina successiva"]","clickType":"clickMore","discardInitialElements":"do-not-discard","clickElementUniquenessType":"uniqueText"},{"id":"type","type":"SelectorText","parentSelectors":["activity"],"selector":"span.section-rating-term span button","multiple":false,"regex":"","delay":0},{"id":"has_business","type":"SelectorText","parentSelectors":["activity"],"selector":"[data-section-id='mcta'] span.widget-pane-link","multiple":false,"regex":"","delay":0},{"id":"GoBack","type":"SelectorElementClick","parentSelectors":["activity"],"selector":"button.section-back-to-list-button span","multiple":false,"delay":"1000","clickElementSelector":"button.section-back-to-list-button span","clickType":"clickMore","discardInitialElements":"do-not-discard","clickElementUniquenessType":"uniqueText"}]}

google map scraping is still an issue i don't know the developers are working to add this as a feature in it or not.
I am also stuck at the same issue.

Don't use the "Next" burrot.
in your root you need to do a multiple link selection of all the page numbers before next.

Then connect your main search element with this element.

my problem is that my database returns nothing although when I do my test everything is getting selected correctly.

This one was a bit tricky, plus I wanted to figure out a way to limit pagination (i.e don't paginate until very end). I finally ended up using the "Showing results x - xx" text as a limiter. Try the sitemap below which will stop at page 5 (identified by "Showing results 81 - 100").

If you want more/fewer pages, you'll need to do some math to figure out the page ranges and then change the Paginator selector,
div.section-layout-root:not(":contains('81 - 100')")

If you don't want any pagination limit (not recommended), you can just remove the :not selector, leaving only:
div.section-layout-root

{"_id":"google_milano_test","startUrl":["https://www.google.com/maps/search/?q=agenzia+pubblicitĂ +milano"],"selectors":[{"id":"Limited paginator","type":"SelectorElementClick","parentSelectors":["_root"],"selector":"div.section-layout-root:not(":contains('81 - 100')")","multiple":true,"delay":"5000","clickElementSelector":"span.n7lv7yjyC35__button-next-icon","clickType":"clickMore","discardInitialElements":"do-not-discard","clickElementUniquenessType":"uniqueText"},{"id":"Row selectors","type":"SelectorElement","parentSelectors":["_root","Limited paginator"],"selector":"div.section-result-text-content","multiple":true,"delay":0},{"id":"Name","type":"SelectorText","parentSelectors":["Row selectors"],"selector":".section-result-title span","multiple":false,"regex":"","delay":0},{"id":"Location","type":"SelectorText","parentSelectors":["Row selectors"],"selector":"span.section-result-location","multiple":false,"regex":"","delay":0},{"id":"Page ranges","type":"SelectorText","parentSelectors":["Limited paginator"],"selector":"span.n7lv7yjyC35__left","multiple":false,"regex":"","delay":0}]}

@leemeng. tried your code but not working :frowning:

Thank you. Couldn't figure it out myself - div.section-layout-root works great.