Python_PPT(5)[1]
Python_PPT(5)[1]
Website
for Online Shopping
•GROUP PROJECT
•405B
•Python
Kartik Bhatt(24BCS11116)
Bismanpreet Singh(24BCS10316)
Rishav Kumar(2BCS10976)
Introduction
A website that
compares prices of
What is a Price
products across
Comparison Website?
different e-commerce
platforms.
Problem Statement
The Problem:
• Tools:
• BeautifulSoup for parsing
HTML.
• Scrapy for large-scale
scraping.
• Selenium for dynamic
pages.
User Interface (UI) Design
Overview
• The UI is simple and user-friendly, allowing users to
search for products and compare prices easily.
Key UI Features
• Search Bar: Prominently placed at the top for easy
access.
• Results Page: Displays the product name, image,
vendor name, and price.
• Navigation: Intuitive menus that guide users
between search results and product details.
Web • Once you've collected and stored price data, the
next step is to build a front-end interface that
Framework: allows users to view and compare prices. This is
Building The where a web framework comes in. Python
provides powerful web frameworks like Flask
Website and Django, each suited for different types of
projects.
Interface
Key Concepts In A Web Framework:
Templates: HTML files that are dynamically rendered by the web server, often
populated with data from the backend.
Database Interaction: Using the backend to retrieve data from a database and
display it to users in a meaningful way.
Forms & User Input: If you want users to search for specific products, you'll need
forms to capture input.
Django: A Full-Featured
Framework
• Security Measures:
• SSL(Secure Sockets Layer)
Encryption for data
protection.
• Avoiding terms of service
violations with scraping.
• Ensuring API rate limits are
respected.
CODE :
import requestsfrom bs4 import BeautifulSoup
# Define URLs of the product pages you want to compareurls = {
"Example Store 1": "https://example1.com/product-page",
"Example Store 2": "https://example2.com/product-page",
"Example Store 3": https://example3.com/product-page
}
# Function to fetch the price from a product page
def fetch_price(url, site_name): try:
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/91.0.4472.124 Safari/537.36"
} response = requests.get(url, headers=headers)
response.raise_for_status()
# Check for request errors soup = BeautifulSoup(response.content, 'html.parser')
# Adjust the following selector according to the website's HTML
structure if site_name == "Example Store 1":
price = soup.select_one(".price-tag-selector").text
elif site_name == "Example Store 2":
price = soup.select_one("#price-id").text
elif site_name == "Example Store 3":
price = soup.select_one(".price-class").text
else:
price = "Price not found"
# Clean the price text and convert it to a float
return float(price.replace("$", "").replace(",", ""))
except Exception as e: print(f"Error fetching price from {site_name}: {e}")
return None#
Main code to compare pricesdef compare_prices(): prices = {}
# Fetch prices from each URL for site_name, url in urls.items():
price = fetch_price(url, site_name) if price is not None:
prices[site_name] = price
# Display comparison results
if prices: sorted_prices = sorted(prices.items(), key=lambda x:
x[1])
print("Price Comparison:")
for site, price in sorted_prices:
print(f"{site}: ${price}")
print(f"\nLowest Price: {sorted_prices[0][0]} at $
{sorted_prices[0][1]}") else:
print("No prices available to compare.")
# Run the price comparison
compare_prices()
Future Enhancements
• Future Plans:
• Mobile app integration.
• Machine Learning for better
product recommendations.
• User account management
for personalized experience.
Conclusion
• Summarize:
• Python is a powerful language for
building price comparison websites.
• The project helps consumers make
better purchasing decisions
efficiently.
• Challenges can be managed with the
right tools and techniques.
Thanks For Your
Attention