    'url': product_div.find('a', class_='product-link')['href']
    }
    products.append(product)

<span class="code-comment"># Save to CSV</span>
with open('products.csv', 'w', newline='', encoding='utf-8') as csvfile:
    fieldnames = ['name', 'price', 'rating', 'url']
    writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
    
    writer.writeheader()
    for product in products:
        writer.writerow(product)

<span class="code-comment"># Save to JSON</span>
with open('products.json', 'w', encod