write me the code for the apple website in python

To write a web scraper for the Apple website in Python, you will need to use the requests library to send HTTP requests to the website and the BeautifulSoup library to parse the HTML content.

Here is an example code to scrape the names and prices of the featured products on the Apple homepage:

main.py
import requests
from bs4 import BeautifulSoup

# Send GET request to Apple homepage
url = 'https://www.apple.com/'
response = requests.get(url)

# Parse HTML content with BeautifulSoup
soup = BeautifulSoup(response.content, 'html.parser')

# Find the featured products section
products_section = soup.find('ul', class_='featured-products')

# Iterate over each featured product and extract its name and price
for product in products_section.find_all('li'):
    name = product.find('h2').text.strip()
    price = product.find('span', class_='current_price').text.strip()
    print(f'{name}: {price}')
600 chars
19 lines

Note: This code is provided for learning purposes only. Web scraping may violate the terms of service of some websites, so use it responsibly and at your own risk.

gistlibby LogSnag