Skip to content
Advertisement

Taking multiple prices on single page BS4

I’m creating an to help me learn but is also useful to me. I want to be able to parse multiple prices from (https://www.watchfinder.co.uk/search?q=114060&orderby=AgeNewToOld) one page, convert them to numbers and average them. The page will change so it could have 3 prices one day and 20 the next. The part i am struggling with is separating the prices so that i can use them. So far i have:

JavaScript

Which gives me

JavaScript

Baring in mind that the amount of prices can change, how can I separate these? Or is there a way with BS4 that can get all these without forlooping?

Advertisement

Answer

This will provide the average value for all prices,

JavaScript

output:

[9250, 8750, 8450]

8816.666666666666

Advertisement