# Import the necessary libraries import requests import os # Get the TikTok video URL video_url = "https://www.tiktok.com/embed/video/" + video_id; # Create a new iframe iframe = document.createElement("iframe"); iframe.src = video_url; iframe.style.display = "none"; # Append the iframe to the document document.body.appendChild(iframe); # Wait for the iframe to load iframe.onload = function() { # Get the video element video = iframe.contentWindow.document.querySelector("video"); # Get the video file URL videoUrl = video.src; # Remove the watermark var regex = /watermark=1/g; videoUrl = videoUrl.replace(regex, ""); # Download the video var xhr = new XMLHttpRequest(); xhr.open("GET", videoUrl); xhr.responseType = "blob"; xhr.onload = function() { if (xhr.status === 200) { // Save the video to the local disk var blob = xhr.response; var videoFileName = "tiktok-video-" + video_id + "-no-watermark.mp4"; saveAs(blob, videoFileName); } else { console.log("Error downloading video: " + xhr.status); } }; xhr.send(); };

test

># Import the necessary libraries import requests import os # Get the TikTok user ID user_id = "1234567890" # Create a directory to store the downloaded videos if not os.path.exists("tiktok_videos"): os.mkdir("tiktok_videos") # Get the list of videos for the user url = "https://www.tiktok.com/api/v1/user/" + user_id + "/videos/" response = requests.get(url) videos = response.json()["items"] # Download each video for video in videos: video_url = video["video_url"] video_file_name = video_url.split("/")[-1] with open("tiktok_videos/" + video_file_name, "wb") as f: f.write(requests.get(video_url).content)

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.