import requests import re from bs4 import BeautifulSoup def no_wotemark_video(url_for_no_wotemark_video): session = requests.Session() url = "https://ssstiktok.io/results" tickTokUrl = url_for_no_wotemark_video splits = tickTokUrl.split("/"); videoId = splits[len(splits) - 1] headers = { "Host": "ssstiktok.io", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0", "Accept": "text/html-partial, */*; q=0.9", "Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "X-IC-Request": "true", "X-HTTP-Method-Override": "POST", "X-Requested-With": "XMLHttpRequest", "Content-Length": "329", "Origin": "https://ssstiktok.io", "Connection": "keep-alive", "TE": "Trailers", "Pragma": "no-cache", "Cache-Control": "no-cache", "Cookie": "__cfduid=dbf0d8ab302c911cdb6c334bce514d20c1592822426; PHPSESSID=337c2h2tmvcv6p8pe98flfih5f; lang=ru; __gads=ID=00cd17aed5494363:T=1592822428:S=ALNI_MZAGyZ8fryNAxzHzpemOaPg8iMzKw; _ga=GA1.2.1811115897.1592822429; _gid=GA1.2.861703323.1592822429; _gat_UA-3524196-6=1; __atuvc=7%7C26; __atuvs=5ef0a0dc805549e9005", } body = { 'ic-request': 'true', 'id': tickTokUrl, 'ic-element-id': 'main_page_form', 'ic-id': '1', 'ic-target-id': 'active_container', 'ic-trigger-id': 'main_page_form', 'token': '765a943f8ad513d18f3f22d69d562d09l90e78d6b4468ac23d9a19d819ce2f36f', 'ic-current-url': '/ru', 'ic-select-from-response': '#idbaeddf', '_method': 'POST' } # запрос видео с сервиса, получаес ответ в виде html data = session.post(url, headers=headers, data=body).content print(data) soup = BeautifulSoup(data, 'lxml') aHref = soup.findAll('a', class_='btn btn-primary download_link without_watermark') # найденна ли необходимая ссылка if aHref is not None: href_conntent = aHref[0].get("href") print('Чистое видео:',href_conntent) else: print("Что-то пошло не так, не найден элемент или ссылка") #videoRaw = session.get(href_conntent).content #return videoRaw url_for_no_wotemark_video = 'https://www.tiktok.com/@food_surgery.x0/video/6840053615961427205' url_for_no_wotemark_video = 'https://www.tiktok.com/@retouch_bigmother/video/6837486240971902214?lang=ru' video = no_wotemark_video(url_for_no_wotemark_video) print(video)