import requests def getHTMLText(self): try: for i in range(0,20): r = requests.get(url, timeout=30) r.raise_for_status() r.encoding = ‘utf-8‘ return r.status_code,r.text,r.content,len(r.text),len(r.content) except: return "" url = "https://cn.bing.com/" print(getHTMLText(url))
结果太长(只截一部分)