headers数据解密
小红书x-sign
def get_x_sign(api):
x_sign = "X"
m = hashlib.md5()
m.update((api + "WSUDD").encode())
x_sign = x_sign + m.hexdigest()
return x_sign
host = 'https://www.xiaohongshu.com'
url = '/fe_api/burdock/weixin/v2/search/notes?keyword={}&sortBy={}' \
'&page={}&pageSize=20&prependNoteIds=&needGifCover=true'.format(parse.quote(keyword),
sort_by,
d_page + 1)
#:param keyword:
#:param d_page: 页数
#:param sort_by: general:综合排序,hot_desc:热度排序
# header的'X-Sign': get_x_sign(url)
代理
def get_proxy():
return requests.get("http://:5010/get/").text
proxies = {'http': "http://{}".format(get_proxy())}
resp = requests.get(url=url, headers=headers, proxies=proxies, timeout=5)