刘煜晨的作业二

代码


import requests
import re
from  bs4 import BeautifulSoup

url = 'http://www.jxufe.edu.cn/'
r = requests.get(url)
r.encoding = 'utf-8'
html = r.text
soup = BeautifulSoup(html) #通过BeautifulSoup美化代码
text1 = soup.get_text() #运用soup中的get_text获取文字
text2 = re.sub('\n{2,}','\n',text1)

结果

结果截图

解释