Element Click on button that has different id in each pages, how to scrape?

Hi, I'm trying to capture text that appears after clicking a specific button. The problem is that this button has a different ID for each page, so when I start scraping, it only extracts the text from the button I specified to automate the click. How can I standardize that this click is for the same button on each page?.

The expected behavior is that you first navigate through each page, access the details of each profile, scrape the profile name, click on the phone, website and email buttons to copy the text that is displayed.

Url: CONSTRUCCIONES en Santo Domingo | Páginas Amarillas

Sitemap:
{"_id":"paginas_amarillas","startUrl":["https://paginasamarillas.com.do/es/business/search/santo-domingo/c/construcciones?sort=alpha"],"selectors":[{"id":"detalle","linkType":"linkFromHref","multiple":true,"parentSelectors":["pagina"],"selector":".yp-result-card-external-information a[data-component]","type":"SelectorLink"},{"id":"pagina","paginationType":"auto","parentSelectors":["_root","pagina"],"selector":"a.p-paginator-page, a.p-paginator-next","type":"SelectorPagination"},{"clickActionType":"real","clickElementSelector":"div.close-floating-buttons","clickElementUniquenessType":"uniqueText","clickType":"clickOnce","delay":0,"discardInitialElements":"do-not-discard","id":"desplegar","multiple":false,"parentSelectors":["detalle"],"selector":"ul.yp-border-shadow-style","type":"SelectorElementClick"},{"clickActionType":"real","clickElementSelector":"button#B5S30669P257552\\.floating-phone-btn","clickElementUniquenessType":"uniqueText","clickType":"clickOnce","delay":0,"discardInitialElements":"discard-when-click-element-exists","id":"clic_tel","multiple":false,"parentSelectors":["detalle"],"selector":"div.yp-floating-dropdown-style","type":"SelectorElementClick"},{"id":"telefono","multiple":false,"parentSelectors":["clic_tel"],"regex":"","selector":"p.w-3\\/5","type":"SelectorText"},{"clickActionType":"real","clickElementSelector":"button#B5S30669P257552\\.floating-website-btn","clickElementUniquenessType":"uniqueText","clickType":"clickOnce","delay":10,"discardInitialElements":"discard-when-click-element-exists","id":"clic_website","multiple":false,"parentSelectors":["detalle"],"selector":"div.yp-floating-dropdown-style","type":"SelectorElementClick"},{"id":"website","multiple":false,"parentSelectors":["clic_website"],"regex":"","selector":"p","type":"SelectorText"},{"clickActionType":"real","clickElementSelector":"#B5S30669P257552\\.business-profile-emails button","clickElementUniquenessType":"uniqueText","clickType":"clickOnce","delay":20,"discardInitialElements":"discard-when-click-element-exists","id":"clic_email","multiple":false,"parentSelectors":["detalle"],"selector":"div.yp-floating-dropdown-style","type":"SelectorElementClick"},{"id":"nombre","multiple":false,"parentSelectors":["detalle"],"regex":"","selector":"h1","type":"SelectorText"},{"id":"email","multiple":false,"parentSelectors":["clic_email"],"regex":"","selector":"p.font-semibold","type":"SelectorText"}]}

Some of your selectors would fail because they are too specific so would only work on 1 page. You can try using a "wildcard" to deal with the random text. E.g. for tel no, try:

button[id*='floating-phone-btn']

I'd also recommend a small Delay (ms) when using Element click. Around 100-200.

Ref: CSS Selectors Reference

1 Like

You are a hero without a cape, that did the trick. Thank you so much!

1 Like