Commit
·
402be75
1
Parent(s):
bf06733
Update app.py
Browse files
app.py
CHANGED
@@ -75,17 +75,18 @@ def scrape_tokped(nama_barang, num_items):
|
|
75 |
url = f'https://www.tokopedia.com/search?navsource=&page={page}&q={query}&srp_component_id=02.01.00.00&srp_page_id=&srp_page_title=&st='
|
76 |
|
77 |
headers = {
|
78 |
-
'User-Agent': 'Mozilla/5.0 (
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
timeout = 10
|
81 |
-
st.write('----------------#0-----------------')
|
82 |
try :
|
83 |
-
st.write('----------------#1-----------------')
|
84 |
response = requests.get(url, headers = headers, timeout = timeout)
|
85 |
-
st.write('----------------#2-----------------')
|
86 |
response.raise_for_status()
|
87 |
soup = BeautifulSoup(response.text, 'html.parser')
|
88 |
-
st.write('----------------#3-----------------')
|
89 |
product_container_list = soup.find_all('a', class_="pcv3__info-content css-gwkf0u", href = True)
|
90 |
|
91 |
for product_info in product_container_list:
|
|
|
75 |
url = f'https://www.tokopedia.com/search?navsource=&page={page}&q={query}&srp_component_id=02.01.00.00&srp_page_id=&srp_page_title=&st='
|
76 |
|
77 |
headers = {
|
78 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
|
79 |
+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
80 |
+
'Accept-Encoding': 'gzip, deflate, br',
|
81 |
+
'Accept-Language': 'en-US,en;q=0.9,id-ID;q=0.8,id;q=0.7,ja;q=0.6,ru;q=0.5,zh-CN;q=0.4,zh;q=0.3,af;q=0.2,nl;q=0.1',
|
82 |
+
'Cache-Control': 'max-age=0',
|
83 |
+
'Upgrade-Insecure-Requests': '1',
|
84 |
}
|
85 |
timeout = 10
|
|
|
86 |
try :
|
|
|
87 |
response = requests.get(url, headers = headers, timeout = timeout)
|
|
|
88 |
response.raise_for_status()
|
89 |
soup = BeautifulSoup(response.text, 'html.parser')
|
|
|
90 |
product_container_list = soup.find_all('a', class_="pcv3__info-content css-gwkf0u", href = True)
|
91 |
|
92 |
for product_info in product_container_list:
|