requests爬虫get请求
1、简单get请求
url = 'https://www.baidu.com' headers = { 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'zh-CN,zh;q=0.9', 'upgrade-insecure-requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36', # 'cookie': 'xxx;yyy;zzz', # 'referer': 'https://xxx.yyy.zzz' } # 发起get请求 response = requests.get(url, headers=headers, verify=True) # 获取html文本 html_data = response.content.decode() print(html_data) print(len(html_data))