点击评论,出现异步加载的请求

python爬取知乎评论

 

 

import json

import  requests
from lxml import etree
from time import sleep


url = "https://www.zhihu.com/api/v4/answers/974431591/root_comments?order=normal&limit=20&offset=0&status=open"
headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36",
    "Refer":"https://www.zhihu.com/"
}
resp = requests.get(url,headers=headers)
content = resp.content.decode('utf-8')
res = json.loads(content)
print(res['data'])
data = res['data']

for item in data:
    print(item['content'])
    print("*"*30)

 

相关文章:

  • 2018-12-11
  • 2022-02-08
  • 2021-11-11
  • 2021-12-07
  • 2021-07-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-31
  • 2021-11-13
  • 2021-04-23
  • 2021-12-03
  • 2021-04-11
  • 2021-09-09
相关资源
相似解决方案