viking_unet

tiktok download video

Jun 18th, 2020
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.57 KB | None | 0 0
  1. import re
  2. import requests
  3.  
  4. def get_clear_video(tiktok_url):
  5.    
  6.     try:
  7.         session = requests.Session()
  8.         result = session.post('https://ttdownloader.com/download_ajax/', data = {'url' : tiktok_url})
  9.         clear_video_url = re.findall('"(https://[^"]+)"', result.text)[0]
  10.         #print('clear_video_url', clear_video_url)
  11.         return session.get(clear_video_url).content
  12.     except Exception as err: print('err:', err)
  13.  
  14. if __name__ == '__main__':
  15.    
  16.     tiktok_url = 'https://www.tiktok.com/@ceciliaannborne/video/6817602864228207878'
  17.    
  18.     data = get_clear_video(tiktok_url)
  19.     if data:
  20.         with open('video.mp4', 'wb') as f: f.write(data)
  21.     else:
  22.         print('failed to extract clear video')
  23.  
  24.     print('done')
Add Comment
Please, Sign In to add comment