v1.0 import requests import bs4 from bs4 import BeautifulSoup # 获取大学排名网页内容 def getHTMLText(url): try: headers = {'user-agent': 'Mozilla/5.0'} r = requests.get(url, timeout=30, headers=headers) #请求URL超时,产生超时异常 r.raise_for_status() #如果转态不是200,引发HTTPError错误 r.encodin