test
May 12, 2023
0
># 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)