<Response [200]>返回值问题
在尝试python爬虫时,我们常常会遇到<Response [200]>返回值问题,此时将requests.get()参数加上headers即可。
例如:
import requests
url = 'https://music.163.com'
html = requests.get(url)
print(html)
返回<Response [200]>;
import requests
url = 'https://music.163.com'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36 Edg/87.0.664.47'}
html = requests.get(url, headers=headers)
print(html)
print('***’)
print(html.text)
<Response [200]>
***
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="baidu_ssp_verify" content="39f14c78c537175eb4b5192c72d002c1" />
<meta name="baidu-site-verification" content="cNhJHKEzsD" />
<m