The returned data is abnormal, unable to understand, no train of thought, lack of experience, please look at the code, thank you!

import requests
url = "https://www.zhihu.com/people/kaifulee/activities"
headers = {
  "authorization": "oauth c3cef7c66a1843f8b3a9e6a1e3160e20",
  "accept": "application/json, text/plain, */*",
  "accept-encoding": "deflate, br",
  "accept-language": "zh-CN,zh;q=0.9",
  "referer": "https://www.zhihu.com/people/tan-shi-san-57/following",
  "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36",
  "x-udid": "AIBCI1Wl0gyPTn67_E1wN4NxZ3rOI2offMM=",

}

r = requests.get(url, headers=headers)
print(r.headers["content-type"], r.encoding)
print(r.text)

print partial output:

text/html; Charset=utf-8 utf-8
"?" Z "" = "j" t yrb.@ "m" 5H "6" Mj "y" I "3" tA5S "!" W "f"ef" R "BX5"p:" 5A-"K"! $"xr"
"" ~ "2t"% C "p7 |" GA " ("6w"). / 8 "8" Ya "z" L "qX" KN "$Ad" Q0H "f" RY- "V" huZ&JP "<" 5 "5 +" $R ") T" > "2TAi" C " {y", V) M / Qe 9 / 3A / 5G / 2o / 5G% SRR / 5G / 2o / 5G / 3A / 5G / 5G / 5G / 5G / 5G / 5G / 5G / 5G / 5G / 3A / 3A / 3A / 7Q / 3A / 3A / 7Q / 3A / 3A / 5G / 5G / 3A / 3A / 5G / 3A / 3A / 5G / 3A / 3A / 3A / 5G / 3A / 3A / 3A / 3A / 3A

Mar.07,2021

'accept-encoding':' deflate, br',
if you remove this, you will return to normal; what you are returning now is compressed, unless you read the response header and see what compression algorithm is used by the server to decompress it.

Menu