mport requests url="https://www.shanghairanking.cn/" def gethtml(url): try: r=requests.get(url) r.raise_for_status() r.encoding="utf-8" print("text内容:",r.text) except: return "Error!" for i in range(1): print(gethtml(url))