cobalt icon indicating copy to clipboard operation
cobalt copied to clipboard

Adding Support for xiaohongshu.com Website

Open Springshen opened this issue 11 months ago • 3 comments

describe the feature you'd like to see

With a monthly visitation of 300 million in China, and the expectation of even more traffic in the future, support for this site is of great importance.

additional context

https://www.xiaohongshu.com/

Springshen avatar Dec 29 '24 06:12 Springshen

https://github.com/imputnet/cobalt/issues/new?assignees=&labels=service+request&projects=&template=service-request.yml&title=add+support+for+%5Bservice+name%5D

KwiatekMiki avatar Dec 29 '24 11:12 KwiatekMiki

@Springshen please add some example links

dumbmoron avatar Dec 29 '24 21:12 dumbmoron

from #1055:

link samples

shortlink:
http://xhslink.com/a/HFNEzlEk7tP3

share button copies this, so if cobalt can detect the link from this thatd be cool ig:
88 Kimmich发布了一篇小红书笔记,快来看吧! 😆 uvdE5BDEqh0P51h 😆 http://xhslink.com/a/HFNEzlEk7tP3,复制本条信息,打开【小红书】App查看精彩内容!

note that share text link contains a , (not a ,), which social media like Discord parse into the link, and they know this, so they seem to split off everything after ,.

dumbmoron avatar Jan 15 '25 20:01 dumbmoron

I just now noticed og:video tag contains the full video link lol

tizu69 avatar Jan 16 '25 17:01 tizu69

Once you fetch the HTML page from xiaohongshu.com, the data is stored in the window.__INITIAL_STATE__ object after page load, you can get everything you need.

  • window.__INITIAL_STATE__.note.noteDetailMap["note_id"].note.imageList is an image array for image notes
  • window.__INITIAL_STATE__.note.noteDetailMap["note_id"].note.video.media.stream is the video URLs for video notes

Here is how it look like for image notes:

window.INITIAL_STATE.note.noteDetailMap["note_id"].note.imageList object

And here is how it look like for video notes:

window.INITIAL_STATE.note.noteDetailMap["note_id"].note.video.media.stream object

You can try it on your browser console!

Reference: JoeanAmier/XHS-Downloader

Podter avatar Jan 19 '25 08:01 Podter

thanks, will make a pr tomorrow (at my time)

lostdusty avatar Jan 20 '25 01:01 lostdusty

we added support for xiaohongshu in 10.6! it's already available on https://cobalt.tools, go try it!

wukko avatar Jan 21 '25 15:01 wukko