Advertisement
viking_unet

tmp tiktok

Jun 22nd, 2020
1,866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.13 KB | None | 0 0
  1. import requests
  2. import re
  3. from   bs4 import BeautifulSoup
  4.  
  5. def no_wotemark_video(url_for_no_wotemark_video):
  6.     session = requests.Session()
  7.     url = "https://ssstiktok.io/results"
  8.     tickTokUrl = url_for_no_wotemark_video
  9.     splits = tickTokUrl.split("/");
  10.     videoId = splits[len(splits) - 1]
  11.  
  12.     headers = {
  13.     "Host": "ssstiktok.io",
  14.     "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0",
  15.     "Accept": "text/html-partial, */*; q=0.9",
  16.     "Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
  17.     "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
  18.     "X-IC-Request": "true",
  19.     "X-HTTP-Method-Override": "POST",
  20.     "X-Requested-With": "XMLHttpRequest",
  21.     "Content-Length": "329",
  22.     "Origin": "https://ssstiktok.io",
  23.     "Connection": "keep-alive",
  24.     "TE": "Trailers",
  25.     "Pragma": "no-cache",
  26.     "Cache-Control": "no-cache",
  27.     "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",
  28.     }
  29.    
  30.     body = {
  31.     'ic-request': 'true',
  32.     'id': tickTokUrl,
  33.     'ic-element-id': 'main_page_form',
  34.     'ic-id': '1',
  35.     'ic-target-id': 'active_container',
  36.     'ic-trigger-id': 'main_page_form',
  37.     'token': '765a943f8ad513d18f3f22d69d562d09l90e78d6b4468ac23d9a19d819ce2f36f',
  38.     'ic-current-url': '/ru',
  39.     'ic-select-from-response': '#idbaeddf',
  40.     '_method': 'POST'
  41.     }
  42.  
  43.     # запрос видео с сервиса, получаес ответ в виде html
  44.     data = session.post(url, headers=headers, data=body).content
  45.     print(data)
  46.     soup = BeautifulSoup(data, 'lxml')
  47.     aHref = soup.findAll('a', class_='btn btn-primary download_link without_watermark')
  48. # найденна ли необходимая ссылка
  49.     if aHref is not None:
  50.         href_conntent = aHref[0].get("href")
  51.         print('Чистое видео:',href_conntent)
  52.     else:
  53.         print("Что-то пошло не так, не найден элемент или ссылка")
  54.  
  55.     #videoRaw = session.get(href_conntent).content
  56.     #return videoRaw
  57.  
  58. url_for_no_wotemark_video = 'https://www.tiktok.com/@food_surgery.x0/video/6840053615961427205'
  59. url_for_no_wotemark_video = 'https://www.tiktok.com/@retouch_bigmother/video/6837486240971902214?lang=ru'
  60. video = no_wotemark_video(url_for_no_wotemark_video)
  61. print(video)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement