- Open your web browser and go to the desired TikTok profile.
- Press
F12to open the developer console. - Open the console tab and paste the following code to enable continuous scrolling:
let goToBottom = setInterval(() => window.scrollBy(0, 400), 1000);
- If prompted that the code is insecure, type
"allow pasting"in the console and pressEnter.
- If prompted that the code is insecure, type
- Copy and paste the following script into the console to extract video descriptions and URLs:
let arrayVideos = []; console.log('\n'.repeat(50)); // Locate all video containers const videoContainers = document.querySelectorAll('.css-1uqux2o-DivItemContainerV2'); // Adjust this selector if necessary videoContainers.forEach((container, index) => { const descriptionElement = container.querySelector('img[alt]'); // Locate the <img> with description in the alt attribute const videoLinkElement = container.querySelector('a[href^="https://www.tiktok.com/"]'); // Locate the <a> tag with the video URL const description = descriptionElement ? descriptionElement.getAttribute('alt').trim() : 'No description'; // Extract description or default const videoURL = videoLinkElement ? videoLinkElement.href : 'No URL'; // Extract URL or default if (description && videoURL) { arrayVideos.push(`"${description}","${videoURL}"`); // Format as CSV console.log(`Description ${index + 1}: ${description}, URL: ${videoURL}`); } else { console.log(`Missing description or URL for video ${index + 1}.`); } }); // Generate CSV file if (arrayVideos.length > 0) { const csvContent = "Description,URL\n" + arrayVideos.join("\n"); const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'my_data.csv'; a.click(); console.log("CSV file created successfully."); } else { console.log("No data found to export."); }
- A file named
my_data.csvwill be generated. Save it in the same directory where you plan to run the Python script.
- Ensure that Python 3 is installed on your system.
- Open a terminal or command prompt and install
yt-dlpusing:pip install yt-dlp
- Navigate to the directory containing the
tiktok_downloader.pyscript and themy_data.csvfile using:cd /path/to/your/directory - Run the downloader script:
python3 tiktok_downloader.py
- The downloaded TikTok videos will be saved in a directory named
tiktok_videos. - Any videos that failed to download will be logged in a file named
failed_downloads.txtin the same directory. You can manually download these videos if necessary.
- Ensure the TikTok page has fully loaded and scrolled to the bottom before running the export script.
- Adjust the CSS selectors in the script if TikTok's website layout changes.
Happy downloading! 🎥