Hint

🧠 Not sure how to start this project?

Here’s how you can break it down step by step:

  1. Fetch the web page
    Use the requests library to download the HTML content:

import requests
from bs4 import BeautifulSoup

URL = "http://books.toscrape.com/"
response = requests.get(URL)
  1. Parse the HTML with BeautifulSoup
    So you can easily extract the book titles and prices:

soup = BeautifulSoup(response.content, "html.parser")
  1. Find all the book entries on the page
    Each book is inside an <article> tag with class "product_pod":

books = soup.find_all("article", class_="product_pod")
  1. Extract the title and price
    From each article element:

for article in books:
    title = article.h3.a["title"]
    price = article.find("p", class_="price_color").text.strip()
    print(title, price)
  1. Save to an SQLite database
    Use sqlite3 to create a books table (if it doesn’t exist yet) and insert each record:

import sqlite3
conn = sqlite3.connect("books.db")
c = conn.cursor()
c.execute("CREATE TABLE IF NOT EXISTS books (id INTEGER PRIMARY KEY, title TEXT, price TEXT)")
  1. Insert all records efficiently
    With executemany():

c.executemany("INSERT INTO books (title, price) VALUES (?, ?)", list_of_books)
conn.commit()
conn.close()

✅ That’s all you need. Click Show Solution in the project page to see how it all ties together in a clean end-to-end script.