Learn practical skills, build real-world projects, and advance your career

Understanding Web Scraping

Importing BeautifulSoup4

from bs4 import BeautifulSoup

Reading html file

with open("home.html", "r") as html_file:
    content = html_file.read()
    print(content)
<!DOCTYPE html> <html lang="en"> <head> <!--Required meta tags--> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <!--Bootstrap CSS--> <link rel="stylesheet"> <title>My Courses</title> </head> <body> <h1>Hello, Start Learning!</h1> <div class="card" id="card-python-for-bs4"> <div class="card-holder"> Python </div> <div class="card-body"> <h5 class="card-title">Python for begineers</h5> <p class="card-text">If you are new to python, this is the course that you should buy!</p> <a href="#" class="btn btn-primary">Start for 20$</a> </div> </div> <div class="card" id="card-python-for-bs4"> <div class="card-holder"> Python </div> <div class="card-body"> <h5 class="card-title">Python Web Development</h5> <p class="card-text">If you feel enough confident with python, you are ready to learn how to create your own website</p> <a href="#" class="btn btn-primary">Start for 50$</a> </div> </div> <div class="card" id="card-python-for-bs4"> <div class="card-holder"> Python </div> <div class="card-body"> <h5 class="card-title">Python Machine Learning</h5> <p class="card-text">Become a Python Machine Learning master!</p> <a href="#" class="btn btn-primary">Start for 100$</a> </div> </div> </body> </html>