Commit
·
045f2fb
1
Parent(s):
c3fc13c
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,14 @@ 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 |
-
#while len(products) < num_items :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
21 |
soup = BeautifulSoup(response.text, 'html.parser')
|
@@ -44,17 +51,11 @@ def scrape_e_commerce(nama_barang, num_items):
|
|
44 |
product_link = f"https://www.klikindomaret.com{product_href}"
|
45 |
products.append({
|
46 |
'product': product_name,
|
47 |
-
'price': product_price,
|
48 |
'original_price': original_price,
|
49 |
'discount_percentage': discount_percentage,
|
|
|
50 |
'link': product_link
|
51 |
})
|
52 |
-
prop = min(len(products) / num_items,1)
|
53 |
-
my_bar.progress(prop, text=progress_text)
|
54 |
-
|
55 |
-
if len (products) > num_items :
|
56 |
-
products = products[:num_items]
|
57 |
-
break
|
58 |
|
59 |
page += 1
|
60 |
|
|
|
15 |
my_bar = st.progress(len(products), text=progress_text)
|
16 |
|
17 |
for percent_complete in range(num_items):
|
18 |
+
#while len(products) < num_items :
|
19 |
+
prop = min(len(products) / num_items,1)
|
20 |
+
my_bar.progress(prop, text=progress_text)
|
21 |
+
|
22 |
+
if len (products) > num_items :
|
23 |
+
products = products[:num_items]
|
24 |
+
break
|
25 |
+
|
26 |
url = f"https://www.klikindomaret.com/search/?key={query}&categories=&productbrandid=&sortcol=&pagesize=54&page={page}&startprice=&endprice=&attributes=&ShowItem="
|
27 |
response = requests.get(url)
|
28 |
soup = BeautifulSoup(response.text, 'html.parser')
|
|
|
51 |
product_link = f"https://www.klikindomaret.com{product_href}"
|
52 |
products.append({
|
53 |
'product': product_name,
|
|
|
54 |
'original_price': original_price,
|
55 |
'discount_percentage': discount_percentage,
|
56 |
+
'price': product_price,
|
57 |
'link': product_link
|
58 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
page += 1
|
61 |
|