CSS Selector - Moving parts

I'm trying to use the CSS Selector function from a webpage. This webpage is our CRM platform that contains all customer and sale information. The information on this page is not always in the same place, and therefor the snippet often returns an error. Is there a way that I can solve this by coupling up with other functions?

Hello Thomas, welcome to the community!

If the data you're expecting isn't always available, you can add some logic to your snippet in order to mitigate that. For example the snippet below will check in 3 different places using 3 different css classes, in order (.age1, .age2, .age3) and return "No age found" if all fail. You can link as many checks as you need.

{age=catch(extractregex(
{site: text; page=; select=ifneeded; selector=.age1},"Age 1:\d"),catch(extractregex({site: text; page=; select=ifneeded; selector=.age2}, "Age 2:\d"),
catch(extractregex({site: text; page=; select=ifneeded; selector=.age3}, "Age 3:\d"), "No age found")))}

If your regex never changes, then something like this is simpler:

{age=extractregex(
catch({site: text; page=; select=ifneeded; selector=.age1},
catch({site: text; page=; select=ifneeded; selector=.age2},
catch({site: text; page=; select=ifneeded; selector=.age3}, "No age found"))), "Age: \d")}

I hope that's helpful

1 Like

I'm using it as a way to simply insert customer and sale information.

Say for example it is a car that is being sold, we would use the following:

I'm just reaching out to see how the sale of your {site: text; select=ifneeded; selector=#\39 7val-accordion_2\.0\.1--panel\:1 :nth-child(2) > .kQeApS; page=https:/###.com/*} is progressing with...

The selector will use a field on the webpage for car make. This information is not always in the same position on the page, so will return an error
[Error - No match found for selector: "#\39 7val-accordion_2.0.1--panel:1 :nth-child(2) > .kQeApS".]

I'm fairly new to this platform, so any help here would be greatly appreciated.

Hi and welcome!

I've run into similar issues for Microsoft Dynamics, and the fix is usually a different selector.
I've had @Gaurang_Tandon help me with this when I've hit the wall.

It might be better to manually find a more stable selector. Or you could try to use the selector-tool again to get the "new" correct selector, and paste these two so we can spot the differences.

1 Like

Hey Thomas,

Like Benjamin recommended, if the position of the selector changes in the page (it's a different selector, or maybe you need a slighty different regex to get the value you want) you can use the solutions I outlined above to do that. You can also specify a "default" value when none of your selectors exist on the page. In your case something like this may work:

{information=catch({site: text; select=ifneeded; selector=selector_one; page=https:/###.com/},
catch({site: text; select=ifneeded; selector=selector_two; page=https:/###.com/
},
catch({site: text; select=ifneeded; selector=selector_three; page=https:/###.com/*}, "No information found")))}

Make sure to update the "selector" and the "page" on each site command, and to remove or add as you need. I added three just as an example.

I'd be happy to jump on a call and help you set up the command to do what you need, just email us at support@blaze.today