import requests
from bs4 import BeautifulSoup
import re
r = requests.get('http://www.jxufe.edu.cn')
html = r.text
f = open('jxufeedu.html','w',encoding='utf-8')
soup = BeautifulSoup(html)
text = soup.get_text()
text = re.sub("\n"," ",text)
print(text)
首先使用request。get函数获取江西财经大学主页源代码 再创建一个soup对象并获取标签内容,最后用空格替换换行符,打印