第 7 题:一个HTML文件,找出里面的正文。
#!/usr/bin/env python3
# -*- coding : utf-8 -*-
import requests
from bs4 import BeautifulSoup
if __name__ == "__main__":
htmlpath = input('请输入html文件路径:')
with open(htmlpath,'r',encoding='utf-8') as html:
htmlall = html.read()
soup = BeautifulSoup(htmlall)
print(soup.get_text())