naufalnashif commited on
Commit
a1b5c21
·
1 Parent(s): 9f9bdcc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -15,9 +15,6 @@ def scrape_e_commerce(nama_barang, num_items):
15
  my_bar = st.progress(len(products), text=progress_text)
16
 
17
  for percent_complete in range(num_items):
18
- if len (products) > num_items :
19
- products = products[:num_items]
20
- break
21
 
22
  url = f"https://www.klikindomaret.com/search/?key={query}&categories=&productbrandid=&sortcol=&pagesize=54&page={page}&startprice=&endprice=&attributes=&ShowItem="
23
  response = requests.get(url)
@@ -51,7 +48,12 @@ def scrape_e_commerce(nama_barang, num_items):
51
  'discount_percentage': discount_percentage,
52
  'link': product_link
53
  })
54
- prop = min(len(products) / num_items, 1)
 
 
 
 
 
55
  my_bar.progress(prop, text=progress_text)
56
 
57
  page += 1
@@ -85,14 +87,14 @@ if selected_site == "klikindomaret.com":
85
  if not nama_barang:
86
  st.error("Mohon isi Nama Barang.")
87
  else:
88
- data_df = scrape_e_commerce(nama_barang, estimated_num_items)
89
  hidden_data = data_df # Simpan data ke dalam variabel tersembunyi
90
  scraping_done = True # Set scraping_done menjadi True
91
 
92
  if selected_site == "alfagift.com(under maintenance)":
93
  st.error("Sedang dalam pengembangan. Silahkan pilih situs yang lain")
94
 
95
- scraped_products = scrape_e_commerce(nama_barang, estimated_num_items)
96
 
97
 
98
 
 
15
  my_bar = st.progress(len(products), text=progress_text)
16
 
17
  for percent_complete in range(num_items):
 
 
 
18
 
19
  url = f"https://www.klikindomaret.com/search/?key={query}&categories=&productbrandid=&sortcol=&pagesize=54&page={page}&startprice=&endprice=&attributes=&ShowItem="
20
  response = requests.get(url)
 
48
  'discount_percentage': discount_percentage,
49
  'link': product_link
50
  })
51
+ if len (products) > num_items :
52
+ products = products[:num_items]
53
+ prop = len(products) / num_items
54
+ my_bar.progress(prop, text=progress_text)
55
+ break
56
+ prop = len(products) / num_items
57
  my_bar.progress(prop, text=progress_text)
58
 
59
  page += 1
 
87
  if not nama_barang:
88
  st.error("Mohon isi Nama Barang.")
89
  else:
90
+ data_df = scrape_e_commerce(nama_barang, num_items)
91
  hidden_data = data_df # Simpan data ke dalam variabel tersembunyi
92
  scraping_done = True # Set scraping_done menjadi True
93
 
94
  if selected_site == "alfagift.com(under maintenance)":
95
  st.error("Sedang dalam pengembangan. Silahkan pilih situs yang lain")
96
 
97
+ scraped_products = scrape_e_commerce(nama_barang, num_items)
98
 
99
 
100