naufalnashif commited on
Commit
d3c580f
·
1 Parent(s): fb8e0dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -11,11 +11,16 @@ def scrape_e_commerce(nama_barang, num_items):
11
  products = []
12
  page = 1
13
  query = quote(nama_barang)
14
-
 
15
 
16
  for percent_complete in range(num_items):
17
- progress_text = "Scraping in progress. Please wait."
18
- my_bar = st.progress(len(products), text=progress_text)
 
 
 
 
19
 
20
  url = f"https://www.klikindomaret.com/search/?key={query}&categories=&productbrandid=&sortcol=&pagesize=54&page={page}&startprice=&endprice=&attributes=&ShowItem="
21
  response = requests.get(url)
@@ -50,13 +55,6 @@ def scrape_e_commerce(nama_barang, num_items):
50
  'discount_percentage': discount_percentage,
51
  'link': product_link
52
  })
53
- if len (products) > num_items :
54
- products = products[:num_items]
55
- prop = min(len(products) / num_items, 1)
56
- my_bar.progress(prop, text=progress_text)
57
- break
58
- prop = min(len(products) / num_items,1)
59
- my_bar.progress(prop, text=progress_text)
60
 
61
  page += 1
62
 
 
11
  products = []
12
  page = 1
13
  query = quote(nama_barang)
14
+ progress_text = "Scraping in progress. Please wait."
15
+ my_bar = st.progress(len(products), text=progress_text)
16
 
17
  for percent_complete in range(num_items):
18
+
19
+ if len (products) > num_items :
20
+ products = products[:num_items]
21
+ break
22
+ prop = min(len(products) / num_items,1)
23
+ my_bar.progress(prop, text=progress_text)
24
 
25
  url = f"https://www.klikindomaret.com/search/?key={query}&categories=&productbrandid=&sortcol=&pagesize=54&page={page}&startprice=&endprice=&attributes=&ShowItem="
26
  response = requests.get(url)
 
55
  'discount_percentage': discount_percentage,
56
  'link': product_link
57
  })
 
 
 
 
 
 
 
58
 
59
  page += 1
60