from bs4 import BeautifulSoup
import requests
import re
link_to_video = input('link: ')
link = link_to_video.split('?')[0] + '?__a=1'
response = requests.get(link_to_video).text
soup = BeautifulSoup(response, 'lxml')
for heading in soup.find_all(re.compile("^script")):
if heading.text.strip()[0:18] == 'window._sharedData':
arr_link = heading.text.strip('window._sharedData = ').split('video_url')[1].split('"')[2].strip().split('\\u0026')
url = ''
for i in arr_link:
url += i + '&'
print(url)
?__a=1
window._sharedData =