An javascript project to download media from a post in tiktok
Explore the docs »
Table of Contents
This project is about developing tools for downloading media from tiktok post using Node.js. This tool is designed to provide an efficient solution for downloading a large number of files at once.
- Make sure you have the latest Node.js installed. (I'm using node js 19.9.0)
- Clone this repository to your machine.
- Install the dependencies
- npm
npm install
1.start the project locally
npm start
2.follow instructions
thx to thread at https://stackoverflow.com/questions/59690743/scraping-all-videos-from-a-tiktok-profile
You can see at how to catch all link
- Open the target tiktok profile
- Open console menu at your broswer(Iam using brave broswer at Xubuntu) and copy this code
let goToBottom = setInterval(() => window.scrollBy(0, 400), 1000);
- Wait until scrool done, after scrool done copy this code to the console like step 2
clearInterval(goToBottom);
let arrayVideos = [];
console.log('\n'.repeat(50));
const containers = document.querySelectorAll('[class*="-DivItemContainerV2"]');
for (const container of containers) {
const link = container.querySelector('[data-e2e="user-post-item"] a');
const title = container.querySelector('[data-e2e="user-post-item-desc"] a');
if (link.href === 'https://www.tiktok.com/') {
link.href = window.location.href;
}
arrayVideos.push(link.href);
console.log(link.href);
}
- after this copy this code, edit the video_links.txt to change filename
let videoLinks = arrayVideos.filter((link) => link.includes('/video'));
let formattedData = videoLinks.join('\n');
let blob = new Blob([formattedData], { type: 'text/plain' });
let elem = window.document.createElement('a');
elem.href = window.URL.createObjectURL(blob);
elem.download = 'video_links.txt';
document.body.appendChild(elem);
elem.click();
document.body.removeChild(elem);
im run at ubuntu 22.04 jammy, im dont test at windows lmao
put your list at currentfilepath/list
The file downloaded will saved at currentfilepath/media/yourfoldername