use BeautifulSoup import a html file
from bs4 import BeautifulSoup import urllib.request def get_soup(url): page = urllib.request.urlopen(url).read() soup = BeautifulSoup(page, "html.parser") return soup soup = get_soup("https://www.pythonforbeginners.com/beautifulsoup/beautifulsoup-4-python")