Create a Python web scraper that extracts product information (name, price, description) from an e-commerce website and stores the data in a MongoDB database.
PLAINFORMAT
import requests
from bs4 import BeautifulSoup
from pymongo import MongoClient

# Connect to MongoDB
client = MongoClient("mongodb://localhost:27017/")
db = client["ecommerce_db"]
products_collection = db["products"]

# Fetch the e-commerce website page
url = "https://example-ecommerce-website.com"
response = requests.get(url)

# Parse the HTML content
soup = BeautifulSoup(response.content, "html.parser")

# Extract product information
for product in soup.find_all(class_="product"):
    name = product.find(class_="product-name").text.strip()
    price = float(product.find(class_="product-price").text.strip().replace("$", ""))
    description = product.find(class_="product-description").text.strip()

    # Store the data in MongoDB
    products_collection.insert_one({
        "name": name,
        "price": price,
        "description": description
    })

print("Data has been successfully stored in MongoDB.")