环境
win10、mac Python3.9 node.js v4.16
def get_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)
return response
def get_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')
if not data:
# logger.info(f'user_id:{user_id} 笔记列表获取失败')
return None
logger.info(f'成功获取笔记列表')
notes = data.get("notes")
new_notes = list()
for note in notes:
reslut = {}
reslut["note_id"] = note.get("note_id") # 笔记id
reslut["display_title"] = note.get("display_title") # 笔记标题
new_notes.append(reslut)
return new_notes
本文仅供学习交流使用,如侵立删! |
---|
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。