Answers for "beautifulsoup read html"

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

Code answers related to "beautifulsoup read html"

Python Answers by Framework

Browse Popular Code Answers by Language