r = requests.get(url, headers=headers).text
traceId = eval(r[r.find('imageList')+11:r.find(',"cover"')])
url_list = [] for i in traceId:
urls = f"https://ci.xiaohongshu.com/{i['traceId']}" url_list.append(urls) return url_list
'''下载图片''' def download(path,picture_url):
headers = { "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36 QIHU 360SE",
} # for i in range(len(picture_url)): # r = requests.get(picture_url, headers=headers) # with open(fr'{filename}\{filename}{i}.jpg', 'wb') as f: # f.write(r.content) start = time.time() for i in range(len(picture_url)): with open(f'{path}{i}.jpg', 'wb') as v: try:
v.write(requests.get(url=picture_url[i+1], headers=headers).content)
end = time.time()
cost = end - start
print(f'{path} ===>downloaded ===>cost {cost}s') except Exception as e:
print('视频下载错误!')