-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
62 lines (50 loc) · 1.7 KB
/
main.py
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
57
58
59
60
61
62
import config
import openpyxl
def informations(card_name):
city = config.soup.find('a', class_='current-location')
card_name = config.soup.findAll('a', class_='item-card__name')
card_price = config.soup.findAll('span', class_='item-card__prices-price')
card_as = config.soup.findAll('span', class_='item-card__prices-title')
card_prices = config.soup.findAll('div', class_='item-card__debet')
card_inc = config.soup.findAll('div', class_='item-card__instalment')
card_price_p = config.soup.findAll('div', class_='item-card__instalment')
card_info = config.soup.findAll('span', class_='item-card__add-info')
code = config.soup.findAll('a', href=True, class_="item-card__name ddl_product_link")
imgs = config.soup.findAll('img', class_="item-card__image")
link_kaspi = 'https://kaspi.kz'
book = openpyxl.Workbook()
sheet = book.active
sheet['A1'] = 'Name'
sheet['B1'] = "Price"
sheet['C1'] = "Inc"
sheet['D1'] = "Link"
sheet['E1'] = "Img"
row = 2
for name in card_name:
sheet[row][0].value = name.text
row += 1
row = 2
for price in card_prices:
sheet[row][1].value = price.text
row += 1
row = 2
for inc in card_inc:
sheet[row][2].value = inc.text
row += 1
row = 2
for link in code:
first = link['href']
sheet[row][3].value = link_kaspi+first
row += 1
row = 2
for img in imgs:
image = img['src']
sheet[row][3].value = image
row += 1
file_name = input("File name: ")
book.save(file_name+".xlsx")
book.close()
def main():
informations()
if __name__ == '__main__':
main()