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)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM