works. Add processed book and book to go counters displayed

This commit is contained in:
yann 2024-11-14 14:07:04 +01:00
parent d020998add
commit ebd5f5acd4

View File

@ -139,13 +139,17 @@ def main():
# get html from URL # get html from URL
soup = get_html(url) soup = get_html(url)
# init counters
total_books = int(soup.form.strong.text)
processed_books = 0
# go ahead for each category # go ahead for each category
for line in get_category_list(soup, url): for line in get_category_list(soup, url):
category = line[0] category = line[0]
category_url = line[1] category_url = line[1]
# display what category is processed # display what category is processed
print("Traitement de la catégorie : " + category) print("\n Traitement de la catégorie : " + category)
# check if multiple pages and create a URL list # check if multiple pages and create a URL list
url_list = check_for_pages(category_url) url_list = check_for_pages(category_url)
@ -156,6 +160,7 @@ def main():
product_url_list.extend(get_product_url_list(i, url)) product_url_list.extend(get_product_url_list(i, url))
# print("Liste des URL des produits: ", product_url_list) # print("Liste des URL des produits: ", product_url_list)
print("Nombre de livres: ", len(product_url_list)) print("Nombre de livres: ", len(product_url_list))
processed_books += 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 = [] data = []
@ -167,8 +172,11 @@ def main():
data.append(get_data(page_soup, page_url)) data.append(get_data(page_soup, page_url))
print("Done.\n Fichier " + data_output(data, category)) print("Done.\n Fichier " + data_output(data, category))
print("Nombre total de livres traités : ", processed_books)
print("Livres restants à traiter : ", total_books - processed_books)
print("Traitement terminé.")
print("\n Traitement terminé.")
if __name__ == '__main__': if __name__ == '__main__':
main() main()