-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScraping python
More file actions
56 lines (46 loc) · 1.46 KB
/
Scraping python
File metadata and controls
56 lines (46 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import requests
def get_product(result):
grocerys = result['data']['rows']
for grocery in grocerys:
category = grocery['category']['k_name_en']
p_name_ru = grocery['p_name_ru']
p_price_1 = grocery['p_price_1']
p_price_2 = grocery['p_price_2']
p_price_3 = grocery['p_price_3']
p_img = grocery['p_img']
categoryKId = grocery['categoryKId']
p_id = grocery['p_id']
url_img = 'https://api.100haryt.com.tm/img/products/'
url_prod = 'https://100haryt.com.tm/product/'+str(categoryKId)+'/'+str(p_id)
offer = [category, p_name_ru, p_price_1,p_price_2, p_price_3, url_img+p_img, url_prod]
print(offer)
def get_products():
offset = 0
cat_id = 1
off = 0
while True:
params = {
'taze': '',
'premium': '',
'sale': '',
'low': '',
'high': '',
'limit': '50',
'offset': offset,
'smart_id': '',
'cat_id': cat_id,
'sub_id': '',
}
response = requests.get('https://api.100haryt.com.tm/api/filter_products', params=params)
result = response.json()
offset += 50
if len(result['data']['rows']) == 0:
cat_id += 1
offset = off
if cat_id == 25:
break
get_product(result)
def main():
get_products()
if __name__ == '__main__':
main()