From c35f7454a21b44f2f6fb5a4781bb15bd1962ba1f Mon Sep 17 00:00:00 2001 From: yann Date: Thu, 14 Nov 2024 13:20:33 +0100 Subject: [PATCH] add text for fancy output and remove previous print (were testing) --- phase2/main.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/phase2/main.py b/phase2/main.py index 0fa6b83..9db0e3b 100644 --- a/phase2/main.py +++ b/phase2/main.py @@ -52,7 +52,7 @@ def get_product_url_list(url_category_page, url): def main(): # init url = "https://books.toscrape.com/" - category = "fantasy" + category = "default" # get functional variables soup = get_html(url) @@ -64,17 +64,17 @@ def main(): # check if multiple page and get url list url_list = check_for_pages(category_url) - print("Liste des URLs des pages: ", url_list) +# print("Liste des URLs des pages: ", url_list) # get product list for each url_list, extend the main product url list with product_url_list = [] for i in url_list: product_url_list.extend(get_product_url_list(i, url)) # print("Liste des URL des produits: ", product_url_list) -# print("Longueur de la liste: ", len(product_url_list)) + print("Nombre de livres: ", len(product_url_list)) - # combine with phase 1 and write in csv for each url from product_url_list named with category + # combine with phase 1 and write in csv for each url from product_url_list named with category data = [] for page_url in product_url_list: page_soup = get_html(page_url) @@ -83,7 +83,8 @@ def main(): # print(phase1.get_data(page_soup, page_url)) data.append(phase1.get_data(page_soup, page_url)) - phase1.data_output(data, category) + print("Done.\n Fichier " + phase1.data_output(data, category)) + if __name__ == '__main__': main()