Hey I am scraping an HTML site and getting issues when wanting to access some objects.
products = BeautifulSoup(response.text, "html.parser").findAll("div", {"data-rubrik":"Cars"})
^This results in an array of 100+ objects. Each of these objects contains an aria-label looking like that:
<div class="art artikelid an" data-alter="7" data-hauptrubrik="Cars" data-k="1666377008.07714">
<a aria-label="Ford Mustang"></a>
</div>
I want to loop through all of the objects and print the car name (aria-label) for each object.
This would be the right way to archive it in JS:
for (let i = 0; i < products.length; i++) {
let cars = products[i].split('aria-label="')[1].split('"')[0];
}
But i cant get it to work in python this is my attempt:
for cars in products:
print(cars.split('aria-label="')[1].split('"')[0])
I hope someone can help me out. Have a great evening :)