Commit
·
a71e00a
1
Parent(s):
98dbc9e
Update app.py
Browse files
app.py
CHANGED
@@ -67,41 +67,26 @@ def scrape_klikindomaret(nama_barang, num_items):
|
|
67 |
@st.cache_data
|
68 |
def scrape_shopee(nama_barang, num_items):
|
69 |
products = []
|
70 |
-
|
71 |
-
|
72 |
-
#path = ''
|
73 |
-
|
74 |
-
#Customize chrome display
|
75 |
-
#chrome_options = Options()
|
76 |
-
#chrome_options.add_argument('--no-sandbox')
|
77 |
-
#chrome_options.add_argument('--headless')
|
78 |
-
#chrome_options.add_argument('--disable-notifications')
|
79 |
-
#chrome_options.add_argument('--disable-infobars')
|
80 |
|
81 |
-
|
82 |
-
options = webdriver.ChromeOptions()
|
83 |
options.add_argument('--no-sandbox')
|
84 |
options.add_argument('--headless')
|
85 |
options.add_argument('--disable-notifications')
|
86 |
options.add_argument('--disable-infobars')
|
87 |
options.add_argument('--disable-dev-shm-usage')
|
|
|
|
|
88 |
|
89 |
|
90 |
try :
|
91 |
-
|
92 |
-
query = quote(nama_barang)
|
93 |
-
#driver = webdriver.Chrome(executable_path = path, options = chrome_options)
|
94 |
-
driver = webdriver.Chrome(options = options)
|
95 |
url = f'https://shopee.co.id/search?keyword={query}&page={page}'
|
96 |
driver.get(url)
|
97 |
|
98 |
-
|
99 |
-
# Cari elemen berdasarkan tagname HTML
|
100 |
-
html_element = driver.find_element(By.TAG_NAME, "html")
|
101 |
|
102 |
-
# Dapatkan HTML dari elemen
|
103 |
-
html = html_element.get_attribute("innerHTML")
|
104 |
-
#html = driver.execute_script("return document.getElementsByTagName('html')[0].innerHTML")
|
105 |
soup = BeautifulSoup(html, "html.parser")
|
106 |
|
107 |
for i in soup.find_all('div', class_ = "ie3A+n bM+7UW Cve6sh" ):
|
@@ -206,15 +191,15 @@ def scrape_tokped_with_selenium(nama_barang, num_items):
|
|
206 |
products = []
|
207 |
page = 1
|
208 |
query = quote(nama_barang)
|
209 |
-
driver = webdriver.Chrome(options = options)
|
210 |
|
211 |
-
|
212 |
-
options = webdriver.ChromeOptions()
|
213 |
options.add_argument('--no-sandbox')
|
214 |
options.add_argument('--headless')
|
215 |
options.add_argument('--disable-notifications')
|
216 |
options.add_argument('--disable-infobars')
|
217 |
options.add_argument('--disable-dev-shm-usage')
|
|
|
|
|
218 |
|
219 |
while len(products) < num_items :
|
220 |
try :
|
|
|
67 |
@st.cache_data
|
68 |
def scrape_shopee(nama_barang, num_items):
|
69 |
products = []
|
70 |
+
page = 1
|
71 |
+
query = quote(nama_barang)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
+
options = webdriver.FirefoxOptions()
|
|
|
74 |
options.add_argument('--no-sandbox')
|
75 |
options.add_argument('--headless')
|
76 |
options.add_argument('--disable-notifications')
|
77 |
options.add_argument('--disable-infobars')
|
78 |
options.add_argument('--disable-dev-shm-usage')
|
79 |
+
|
80 |
+
driver = webdriver.Firefox(options=options)
|
81 |
|
82 |
|
83 |
try :
|
84 |
+
|
|
|
|
|
|
|
85 |
url = f'https://shopee.co.id/search?keyword={query}&page={page}'
|
86 |
driver.get(url)
|
87 |
|
88 |
+
html = driver.page_source
|
|
|
|
|
89 |
|
|
|
|
|
|
|
90 |
soup = BeautifulSoup(html, "html.parser")
|
91 |
|
92 |
for i in soup.find_all('div', class_ = "ie3A+n bM+7UW Cve6sh" ):
|
|
|
191 |
products = []
|
192 |
page = 1
|
193 |
query = quote(nama_barang)
|
|
|
194 |
|
195 |
+
options = webdriver.FirefoxOptions()
|
|
|
196 |
options.add_argument('--no-sandbox')
|
197 |
options.add_argument('--headless')
|
198 |
options.add_argument('--disable-notifications')
|
199 |
options.add_argument('--disable-infobars')
|
200 |
options.add_argument('--disable-dev-shm-usage')
|
201 |
+
|
202 |
+
driver = webdriver.Firefox(options=options)
|
203 |
|
204 |
while len(products) < num_items :
|
205 |
try :
|