访问网页

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))

结果太长(只截一部分)

访问网页

访问网页

上一篇:[leetcode]Validate Binary Search Tree @ Python


下一篇:.Net生成PDF流