Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import io
- import requests
- video_url = 'https://www.tiktok.com/@ceciliaannborne/video/6817602864228207878'
- r = requests.get(video_url, headers={"method": "GET", "accept-encoding": "utf-8", "user-agent": 'Mazila'})
- content_url = r.text.split("\"contentUrl\":\"")[1].split("\"")[0] # здесь можно сделать проще - заменить регуляркой
- print('content_url =',content_url)
- with requests.get(content_url, stream=True) as response:
- response.raise_for_status()
- pos = response.content.find(b'vid:')
- bs = io.BytesIO(response.content)
- bs.seek(pos+4)
- vid = bs.read(32).decode('utf-8')
- print('vid =',content_url)
- clear_video_url = 'https://api2-16-h2.musical.ly/aweme/v1/play/?video_id={video_id}&vr_type=0&is_play_url=1&source=PackSourceEnum_PUBLISH&media_type=4'
- print('clear_video_url =', clear_video_url)
- response = requests.head(clear_video_url.format(video_id = vid), headers={'user-agent': 'okhttp'}, allow_redirects=True)
- print('true clear url =', response.url)
Add Comment
Please, Sign In to add comment