headers数据解密

小红书x-sign

  1. def get_x_sign(api):
  2. x_sign = "X"
  3. m = hashlib.md5()
  4. m.update((api + "WSUDD").encode())
  5. x_sign = x_sign + m.hexdigest()
  6. return x_sign
  7. host = 'https://www.xiaohongshu.com'
  8. url = '/fe_api/burdock/weixin/v2/search/notes?keyword={}&sortBy={}' \
  9. '&page={}&pageSize=20&prependNoteIds=&needGifCover=true'.format(parse.quote(keyword),
  10. sort_by,
  11. d_page + 1)
  12. #:param keyword:
  13. #:param d_page: 页数
  14. #:param sort_by: general:综合排序,hot_desc:热度排序
  15. # header的'X-Sign': get_x_sign(url)

代理

  1. def get_proxy():
  2. return requests.get("http://:5010/get/").text
  3. proxies = {'http': "http://{}".format(get_proxy())}
  4. resp = requests.get(url=url, headers=headers, proxies=proxies, timeout=5)