Find correct xpath

Hi,

I am trying to scrape the lowest price on a overview page with multiple products. With //*[contains(@class,'price-bottom')]//span I am able to grab a price. However it is not always the product with the lowest price. Could you help me write a xpath for the lowest price?

For example, there could be up to 20 products that have a code like this:

<div class="price-bottom"><sub>vanaf</sub><span>4099</span></div>

<div class="price-bottom"><sub>vanaf</sub><span>2349</span></div>

<div class="price-bottom"><sub>vanaf</sub><span>3099</span></div>

Thanks!

Hi, thanks for an interesting question.

I wasn't able to solve it using the built in XPath operators such as recommended here

However, it is possible using Excel min function and treating the XPath results as an array:

Notice the {} in the formula (CTRL + Shift + Enter).

Hi Diskborste,

Thanks a lot. That would be awesome. However, then I would first need to find all of the xpaths. But if I use my //*[contains(@class,'price-bottom')]//span I only get one price as output. So then I would need a Xpath where I get all the three prices as ouput and I can't figure that out (is used [1],[2], etc. but that doesn't seem to work). After that I could use your function in Excel.

Thanks,

The XPath returns all matches but only outputs one to the cell unless you use the Dump() function. In this case however, the min() function finds the minimum/compares all results before the value is outputted to the sheet. Do you understand what I mean?

Super!! This works, thanks a lot

1 Like