import requests
from bs4 import BeautifulSoup
# Target URL
url = “https://ceylonorganicstore.com/”
# Set user-agent to mimic a browser
headers = {
“User-Agent”: “Mozilla/5.0 (Windows NT 10.0; Win64; x64)”
}
# Send GET request
response = requests.get(url, headers=headers)
# Check response status
if response.status_code == 200:
soup = BeautifulSoup(response.text, “html.parser”)
# Page title
title = soup.title.string if soup.title else “No Title”
print(f”Page Title: {title}\n”)
# Meta description
meta_desc = soup.find(“meta”, attrs={“name”: “description”})
if meta_desc:
print(f”Meta Description: {meta_desc[‘content’]}\n”)
# Navigation menu items
print(“Navigation Menu Items:”)
for link in soup.select(“nav a”):
text = link.get_text(strip=True)
href = link.get(“href”)
if text:
print(f” – {text}: {href}”)
print(“\n”)
# Featured products (if on homepage)
print(“Featured Products:”)
products = soup.select(“.product-title, .product-grid-item, .woocommerce-loop-product__title”)
for i, product in enumerate(products, 1):
product_name = product.get_text(strip=True)
print(f”{i}. {product_name}”)
# Product Prices
print(“\nProduct Prices:”)
prices = soup.select(“.price, .woocommerce-Price-amount”)
for price in prices:
print(f” – {price.get_text(strip=True)}”)
# Product Images
print(“\nProduct Image URLs:”)
images = soup.select(“img”)
for img in images:
src = img.get(“src”)
if src and “product” in src:
print(f” – {src}”)
else:
print(f”Failed to access the page. Status code: {response.status_code}”)