4

I am trying to save videos from this url:

Original:

https://api2.musical.ly/aweme/v1/play/?video_id=v09044a20000beeff4c108gs7sflfdug

Link changes to this:

http://v16.muscdn.com/3d238aa3e1c34000ce53792155cd0e15/5bcf3070/video/tos/maliva/tos-maliva-v-0068/e5a1ab74d0b54f97b3578924a428e58d/

The video is from TikTok. When you go to the url, it instantly redirects you to another url. The other url is the one I want in order to save the video. However, the url it directs you to does not have a "view html source" option. I can inspect the element and that shows it has a video tag, but I cannot find a way to save the url between the tag. I am using python and beautifulsoup. I tried to do this with selenium, but to no effect.

SomeGuyOnAComputer
  • 5,414
  • 6
  • 40
  • 72
VickTree
  • 889
  • 11
  • 26

1 Answers1

4

Edit:

The link that it redirects to changes all the time! as of 27/08/2019, the link below works...

If you get Access denied you should check the link once again...

I think you should use other libraries for saving videos...

For example (in Python 3+):

import urllib.request


vid_url = "http://v19.muscdn.com/21b98c731608b8aa296ec31468c26dd1/5d652a88/video/tos/maliva/tos-maliva-v-0068/e5a1ab74d0b54f97b3578924a428e58d/?rc=amdvdnY7NDdpaDMzNTczM0ApdSlINzU2NTM0MzM2MzM1MzQ1b2k5ZmU5Z2c1ZGY5ZmQzPGZAaUBoNnYpQGczdilAZjY1QHJjYzRkLWBjYl8tLV4xNnNzOmk0NTU1LjQtLi4uMTQ0NTYtOiM2MDAtXjQzXzMxMTFeMWEzYSNvIzphLW8jOmAtbyMwLl4%3D"

urllib.request.urlretrieve(vid_url, "your_video_name.mp4")

If you insist on using selenium you can add options like this:

options = webdriver.ChromeOptions()
options.add_experimental_option("prefs", {
   "download.default_directory": r"C:\Users\xxx\downloads\Test",
   "download.prompt_for_download": False,
   "download.directory_upgrade": True,
   "safebrowsing.enabled": True
})
driver = webdriver.Chrome(chrome_options=options)

Hope this helps you!

Community
  • 1
  • 1
Moshe Slavin
  • 5,127
  • 5
  • 23
  • 38
  • 2
    i ran the request code and had error: ` http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) HTTPError: Forbidden` - is it because the link expired? Thanks – YJZ Aug 25 '19 at 03:39
  • 2
    @YJZ Yes you are correct the link has expired. I have updated the link to fit OP's question. Thanks! – Moshe Slavin Aug 25 '19 at 06:13
  • 2
    Thank you @Moshe Slavin! I updated the link and still have the same error - is there something I can test? (When I put that url into browser, it says `Access to v16.tiktokcdn.com was denied`) Let me know please. Thank you so much! – YJZ Aug 27 '19 at 01:04
  • 2
    @YJZ the link has changed again! – Moshe Slavin Aug 27 '19 at 07:08
  • can you please tell me how can i download the video without watermark from video url? – Mateen Chaudhry Jan 30 '20 at 15:35
  • @MateenChaudhry The real question is if the video on the server is with the watermark or not! – Moshe Slavin Jan 30 '20 at 15:56