資源簡介
使用python 獲取知乎用戶粉絲
代碼片段和文件信息
‘‘‘
title?=?知乎粉絲抓取
date?=?2019-11-17
‘‘‘
#導入模塊
import?requests
#創建一個類
class?ZhiHu:
????#定義一個初始化函數
????def?__init__(self):
????????#初始化網址?提前賦值網址
????????self.url=‘https://www.zhihu.com/api/v4/members/WaJueJiPrince/followers?include=data%5B*%5D.answer_count%2Carticles_count%2Cgender%2Cfollower_count%2Cis_followed%2Cis_following%2Cbadge%5B%3F(type%3Dbest_answerer)%5D.topics&offset=40&limit=20‘
????????#反爬措施
????????self.header?=?{‘user-agent‘:?‘Mozilla/5.0?(Windows?NT?10.0;?WOW64)?AppleWebKit/537.36?(KHTML?like?Gecko)?Chrome/69.0.3497.100?Safari/537.36‘}
????def?getFenSi(selfparam):#得到粉絲
??????
???????#請求json文件到本地
???????self.html?=?requests.get(self.urlparams=paramheaders=self.header)??#得到文本文件并解析
???????#批量提取json文件里面的數據
???????for?n?in?range(20):
???????????
???????????#print(self.html)
???????????id?=?(self.html.json
評論
共有 條評論