From c0fcd213466a5e1ad54a025844bdb86c0d6aaf60 Mon Sep 17 00:00:00 2001 From: yann Date: Wed, 13 Nov 2024 13:44:27 +0100 Subject: [PATCH] add get_category --- phase1/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phase1/main.py b/phase1/main.py index a2968a9..a8864e6 100644 --- a/phase1/main.py +++ b/phase1/main.py @@ -36,6 +36,11 @@ def product_description(soup): desc = soup.find("p", class_='').string return desc +# get category from breadcrumb +def get_category(soup): + bread = soup.find("ul", class_="breadcrumb").find_all("a")[-1].text + return bread + #create a list with all information consecutively # /!\ don't know if that's the best way def get_data(soup, url): @@ -45,7 +50,7 @@ def get_data(soup, url): product_information(soup)['Price (excl. tax)'], product_information(soup)['Availability'], product_description(soup), - "TODO", + get_category(soup), product_information(soup)['Number of reviews'], get_image_url(soup, url) ]