import requests import base64 import json import time import re session = requests.Session() class authentication(): def __init__(self, path_cookies='', username='', password=''): self._path_cookies = path_cookies self._username = username self._password = password self.session = session def auth_with_cookies(self): file = open(self._path_cookies, 'r', encoding='utf-8') cookies = {} out = '' csrf_token = "" for line in file: line = line.strip() if '#' not in line: item = re.findall(r'[0-9]\s(.*)', line) if item: item = item[0].split('\t') if len(item) == 1: cookies[item[0]] = '' out += "%s=''; " % item[0] else: cookies[item[0]] = item[1] if item[0] == 'XSRF-TOKEN': csrf_token = item[1] self.session.cookies.update(cookies) return csrf_token def hash(): _secretKey = "vnlinks.net" _accessKey = 192 msg = _secretKey + ":" + str(int(time.time()*1000)) msgBase64 = base64.b64encode(msg.encode()).decode() result = [] for i in msgBase64: charCode = ord(i) xor_enc = charCode ^ _accessKey result.append(xor_enc) return base64.b64encode(bytearray(result)).decode("utf-8-sig") def get_link(link,csrf_token): print(csrf_token) print(link) for i in range(10): vnlink_header = { "User-Agent":"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/86.0.170 Chrome/80.0.3987.170 Safari/537.36", "Sec-Fetch-Site":"same-origin", "Sec-Fetch-Mode":"cors", "Sec-Fetch-Dest":"empty", "Referer":"https://vnlinks.net/", "Origin":"https://vnlinks.net", "X-Api-Key":hash(), "Content-Type": "application/json;charset=UTF-8", "X-XSRF-TOKEN":csrf_token, "Content-Length":"122", "Host":"vnlinks.net", "Lang":"vi" } info = session.post(url="https://vnlinks.net/get-link",headers=vnlink_header,data={ "provider":"1fichier.com", "link":link, "password":"", "captcha":"", "callback":None }) info_json = info.json() print(info_json) # if info_json.get("status"): # print(info_json.get("downloadLink")) # else: # print("error %s" % i) auth = authentication(path_cookies="cookies.txt") csrf_token = auth.auth_with_cookies() get_link("https://1fichier.com/?p6saxszcohw8rd7x2mnz",csrf_token)