tiktok-post-dl

An javascript project to download media from a post in tiktok
Explore the docs »

Table of Contents
  1. About The Project
  2. Getting Started
  3. How to run
  4. Get all post url from profile

About The Project

About

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.

(back to top)

Built With

JavaScript

(back to top)

Getting Started

  1. Make sure you have the latest Node.js installed. (I'm using node js 19.9.0)
  2. Clone this repository to your machine.
  3. Install the dependencies

How To Run

1.start the project locally

 npm start

2.follow instructions

Get all post url from profile

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

  1. Open the target tiktok profile
  2. Open console menu at your broswer(Iam using brave broswer at Xubuntu) and copy this code
let goToBottom = setInterval(() => window.scrollBy(0, 400), 1000);
  1. 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);
}
  1. 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);

(back to top)

Notes

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


(back to top)