小白,‘url’没有获取到?
import requests def getHTMLText(url): try: r.requests.get(url,timeout=30) r.raise_for_status() r.encoding = r.apparent_encoding return r.text except: return "报异常" if __name__=="main": url = "http://baidu.com" print(getHTMLText(url)
import requests def getHTMLText(url): try: r.requests.get(url,timeout=30) r.raise_for_status() r.encoding = r.apparent_encoding return r.text except: return "报异常" if __name__=="main": url = "http://baidu.com" print(getHTMLText(url)
2017-06-22
举报