add get_category

This commit is contained in:
yann 2024-11-13 13:44:27 +01:00
parent 7b7f216be8
commit c0fcd21346

View File

@ -36,6 +36,11 @@ def product_description(soup):
desc = soup.find("p", class_='').string desc = soup.find("p", class_='').string
return desc 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 #create a list with all information consecutively
# /!\ don't know if that's the best way # /!\ don't know if that's the best way
def get_data(soup, url): def get_data(soup, url):
@ -45,7 +50,7 @@ def get_data(soup, url):
product_information(soup)['Price (excl. tax)'], product_information(soup)['Price (excl. tax)'],
product_information(soup)['Availability'], product_information(soup)['Availability'],
product_description(soup), product_description(soup),
"TODO", get_category(soup),
product_information(soup)['Number of reviews'], product_information(soup)['Number of reviews'],
get_image_url(soup, url) get_image_url(soup, url)
] ]