-
import requests def getHTMLText(url): try: headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"} r = requests.get(url,headers = headers) r.encoding = r.apparent_encoding return r.text except: print("URL错误:",url)