快手获取关注列表,搭配爬取视频。效果更好
本帖最后由 TZ糖纸 于 2021-4-22 19:44 编辑import json
import re
import os
import requests
import urllib.request
import KuaiShou2
requestUrl = 'https://video.kuaishou.com/graphql'
Cookie = ''
def post(pcursor):
data = {"operationName":"visionProfileUserList","variables":{"ftype":1,"pcursor":pcursor},"query":"query visionProfileUserList($pcursor: String, $ftype: Int) {\nvisionProfileUserList(pcursor: $pcursor, ftype: $ftype) {\n result\n fols {\n user_name\n headurl\n user_text\n isFollowing\n user_id\n __typename\n }\n hostName\n pcursor\n __typename\n}\n}\n"}
failed = {'msg': 'failed...'}
headers = {
'Host':'video.kuaishou.com',
'Connection':'keep-alive',
'Content-Length':'1261',
'accept':'*/*',
'User-Agent':'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/89.0.4389.114Safari/537.36Edg/89.0.774.68',
'content-type':'application/json',
'Origin':'https://video.kuaishou.com',
'Sec-Fetch-Site':'same-origin',
'Sec-Fetch-Mode':'cors',
'Sec-Fetch-Dest':'empty',
'Accept-Language':'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
'Cookie':Cookie,
}
r = requests.post(requestUrl, data=json.dumps(data), headers=headers)
r.encoding = 'UTF-8'
html = r.text
return html
if __name__ == "__main__":
userList = []
for i in range(1,10):
result = post(i * 30)
data = json.loads(result)
fols = data['data']['visionProfileUserList']['fols']
for user in fols:
userList.append(user['user_id'])
KuaiShou2.Start(userList)
KuaiShou2在上篇帖子有
传送门:https://www.52pojie.cn/thread-1414901-1-1.html 刚好再找这个,谢谢楼主 这个干嘛用
特百惠 发表于 2021-4-19 14:40
这个干嘛用
给用需要的人用啊 附上一篇:https://www.52pojie.cn/thread-1414901-1-1.html 这样子了怎么办啊
页:
[1]