首先以此 网站 为目标路径
1、所需要的库
requests
2、对以瀑布流的json数据进行解析
data={
'limit':20,
'offset':20
}
3、代码演示
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2018/3/13 15:40
# @Author : tomorrowli
import requests
class Zhuhu():
#初始化参数
def __init__(self):
#赋值网址
self.url = 'https://zhuanlan.zhihu.com/api/columns/wajuejiprince/followers'
self.headers={
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36'
}
def getMesg(self,param):
self.html=requests.get(self.url,params=param,headers=self.headers)
for m in range(20):
'''
with open('zhihu.txt','a') as f:
print(self.html.json()[m]['hash'])
f.write(self.html.json()[m]['hash']+'\n')
'''
data={
'bio':self.html.json()[m]['bio'],
'name':self.html.json()[m]['name'],
'profileUrl':self.html.json()[m]['profileUrl'],
'hash':self.html.json()[m]['hash']
}
print(data)
def main():
for n in range(0,60,20):
data={
'limit':20,
'offset':n
}
zhihu=Zhuhu()
zhihu.getMesg(data)
if __name__ == '__main__':
main()
4、可以为每个粉丝进行发私信
需要获取每个粉丝的hash和自己cookie值