import json
from bs4 import BeautifulSoup

with open('store.html', encoding='utf-8') as f:
    html = f.read()
soup = BeautifulSoup(html, 'html.parser')

for tag in soup.select('.price'):
    print(tag.text)
for link in soup.select('div.product > a'):
    print(link['href'], link.text)
print('Prices:', len(soup.select('.price')))

products = []
for product in soup.select('div.product'):
    link = product.select('a')[0]
    price = product.select('.price')[0]
    products.append({
        'name': link.text,
        'price': price.text,
        'href': link['href'],
    })
print(products[0])
print('Products:', len(products))

with open('products.json', 'w', encoding='utf-8') as f:
    json.dump(products, f, indent=2)
print('Saved products.json')
