from bs4 import BeautifulSoup import re import requests r = requests.get('http://www.jxufe.edu.cn') html = r.text soup = BeautifulSoup(html) text = soup.get_text()#通过函数直接获取标签内文字 text_final = re.sub("\n"," ",text)#将换行符替换为空格