how to load html file from pc in python using bs4 code example
Example: how to load html file from pc in python using bs4
#!/usr/bin/python
from bs4 import BeautifulSoup
with open('index.html', 'r') as f:
contents = f.read()
soup = BeautifulSoup(contents, 'lxml')
tags = soup.find_all(['h2', 'p'])
for tag in tags:
print(' '.join(tag.text.split()))