Answers for "open html file beautifulsoup"

1

beautifulsoup open html file

#!/usr/bin/python

from bs4 import BeautifulSoup

with open('index.html', 'r') as f:

    contents = f.read()

    soup = BeautifulSoup(contents, 'lxml')

    print(soup.h2)
    print(soup.head)
    print(soup.li)
Posted by: Guest on May-15-2021

Python Answers by Framework

Browse Popular Code Answers by Language