Commit
·
90310fc
1
Parent(s):
4a8f878
Update app.py
Browse files
app.py
CHANGED
@@ -14,7 +14,13 @@ def scrape_e_commerce(nama_barang, num_items):
|
|
14 |
progress_text = "Scraping in progress. Please wait."
|
15 |
my_bar = st.progress(len(products), text=progress_text)
|
16 |
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
url = f"https://www.klikindomaret.com/search/?key={query}&categories=&productbrandid=&sortcol=&pagesize=54&page={page}&startprice=&endprice=&attributes=&ShowItem="
|
19 |
response = requests.get(url)
|
20 |
soup = BeautifulSoup(response.text, 'html.parser')
|
@@ -32,12 +38,7 @@ def scrape_e_commerce(nama_barang, num_items):
|
|
32 |
'price': product_price,
|
33 |
'link': product_link
|
34 |
})
|
35 |
-
|
36 |
-
prop = min(len(products) / num_items, 1)
|
37 |
-
my_bar.progress(prop, text=progress_text)
|
38 |
-
if len (products) > num_items :
|
39 |
-
products = products[:num_items]
|
40 |
-
break
|
41 |
page += 1
|
42 |
|
43 |
time.sleep(1)
|
|
|
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 |
+
if len (products) > num_items :
|
19 |
+
products = products[:num_items]
|
20 |
+
break
|
21 |
+
|
22 |
+
prop = min(len(products) / num_items, 1)
|
23 |
+
my_bar.progress(prop, text=progress_text)
|
24 |
url = f"https://www.klikindomaret.com/search/?key={query}&categories=&productbrandid=&sortcol=&pagesize=54&page={page}&startprice=&endprice=&attributes=&ShowItem="
|
25 |
response = requests.get(url)
|
26 |
soup = BeautifulSoup(response.text, 'html.parser')
|
|
|
38 |
'price': product_price,
|
39 |
'link': product_link
|
40 |
})
|
41 |
+
|
|
|
|
|
|
|
|
|
|
|
42 |
page += 1
|
43 |
|
44 |
time.sleep(1)
|