本文所有教程及源码、软件仅为技术研究。不涉及计算机信息系统功能的删除、修改、增加、干扰,更不会影响计算机信息系统的正常运行。不得将代码用于非法用途,如侵立删! |
标题
环境
- win10、mac
- Python3.9
- node.js v4.16
x-s、x-t、a1、web_session
获取博主详细信息
defget_user_info(self, user_id):
"""
个人信息接口
user_id: 用户id
"""
headers= {
"Host": "edith.xiaohongshu.com",
"sec-ch-ua": "\"Chromium\";v=\"104\", \" Not A;Brand\";v=\"99\", \"Google Chrome\";v=\"104\"",
"x-t": "1684659937276",
"x-b3-traceid": "01eeabcb94ba947e",
"sec-ch-ua-mobile": "?0",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
"accept": "application/json, text/plain, */*",
"x-s": "XYW_eyJzaWduU3ZuIjoiNTAiLCJzaWduVHlwZSI6IngxIiwiYXBwSWQiOiJ4aHMtcGMtd2ViIiwic2lnblZlcnNpb24iOiIxIiwicGF5bG9hZCI6IjRjMzUyYmUyMDE0OTAyMjM1OTQxMDM1ODNlNjRmN2UyMmYwZmMyMTVlYmU5YWU3ZjNkMDFiZDNkNWYzNDUzMWY0NDkwZmQ1ZmU2NDdjNzZmOGE3OTdiOWZlODcwZmRjZDE2ZTJlM2JmYjg5ZTJkYTFkYWQ2MWM1MDQxZDZhYzJiZGFkNjFjNTA0MWQ2YWMyYmJhMWM0ZmNjNTUyMGEzZTNmOWY2Yjk1M2ZmODE5ZjdjNGQzOTY0ZDYxMDQwNWVmYTQyNzgxN2UyZTJlNDI2OGNhYzhhNDA5N2Q0M2VhMzNhYWM0ZjFlNjRjM2JlZGY0NGIxZmYwODBiZDc5NzcxY2JmMWRmM2RmZTA4OTYyMDIwNmUzZmFjYTY1NGVlYjUwNTNjY2E0MGViODY2NGI1OWQ1NjRkNTVmNDM3ZmJiMDNkY2JjMjM2MjM0ZmMyZjQwYTg1ZjQ2MWJhZGY5YzZhZTNlZGQ4NDU0NmUzOWUxZjNmZTYwMjM1ZjFhYTc3MzM3MSJ9",
"sec-ch-ua-platform": "\"Windows\"",
"origin": "https://www.xiaohongshu.com",
"sec-fetch-site": "same-site",
"sec-fetch-mode": "cors",
"sec-fetch-dest": "empty",
"referer": "https://www.xiaohongshu.com/",
"accept-language": "zh-CN,zh;q=0.9",
"cookie": cookie_str
}
params= {
"target_user_id": user_id
}
headers.update({'x-s': sign.get('X-s'), 'x-t': str(sign.get('X-t'))})
response=requests.get(url, headers=headers, params=params, proxies=self.proxies)
returnresponse
根据user_id查询笔记列表
defget_aweme_list(self, user_id):
"""
根据作者id查询笔记列表
user_id:作者id
"""
headers= {
"Accept": "application/json, text/plain, */*",
"Accept-Language": "zh-CN,zh;q=0.9",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Origin": "https://www.xiaohongshu.com",
"Pragma": "no-cache",
"Referer": "https://www.xiaohongshu.com/",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
"X-s": "XYW_eyJzaWduU3ZuIjoiNTAiLCJzaWduVHlwZSI6IngxIiwiYXBwSWQiOiJ4aHMtcGMtd2ViIiwic2lnblZlcnNpb24iOiIxIiwicGF5bG9hZCI6IjE2ZTM5YWVkYTk4YWQyNTU0NmViNmVhZGY5Y2FiYmQ0ZDg3Y2RjZjQ2ZWJkMGI1ODMxOTQ1YzQzMjljZDE5NTBhM2QyYjM1MTJkMTY3NjYwNGY5YjJmYTI2OTVmNDVmZTE2ZTJlM2JmYjg5ZTJkYTFkYWQ2MWM1MDQxZDZhYzJiZGFkNjFjNTA0MWQ2YWMyYmJhMWM0ZmNjNTUyMGEzZTNmOWY2Yjk1M2ZmODE5ZjdjNGQzOTY0ZDYxMDQwNWVmYTA1NGE4OTY1YjAwMTU2MGJmZGJiZGZmODBiZDcwNjI5N2I3ZmNmOTQ0ZDI0ZGI5ZDBiZjk0NTIyMzIxNjdlYTk1YjliZGQ3MTE1MDEyMjJhZTFiMDhkNTY1NmFkNTI4MWZhYzlmYjBiZDY0ODBmMjA0MTQ2NzliOGY1MTljZDA4MzE2Y2QyODRkZjhhYTIyOTg1ZjQ2MWJhZGY5YzZhZTMxMzYyYTFlZDdkNmYxZWQ1OTczZTQ0OGExNDAzM2ZiNiJ9",
"X-t": "1684406468688",
"sec-ch-ua": "\"Chromium\";v=\"104\", \" Not A;Brand\";v=\"99\", \"Google Chrome\";v=\"104\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"cookie": cookie_str
}
params= {
"num": "30",
"cursor": "",
"user_id": user_id
}
headers.update({'X-s': sign.get('X-s'), 'X-t': str(sign.get('X-t'))})
response=requests.get(url, headers=headers, params=params, proxies=self.proxies, timeout=30)
data=response.json().get('data')
ifnotdata:
# logger.info(f'user_id:{user_id} 笔记列表获取失败')
returnNone
logger.info(f'成功获取笔记列表')
notes=data.get("notes")
new_notes=list()
fornoteinnotes:
reslut= {}
reslut["note_id"] =note.get("note_id") # 笔记id
reslut["display_title"] =note.get("display_title") # 笔记标题
new_notes.append(reslut)
returnnew_notes
效果
本文仅供学习交流使用,如侵立删! |