def cm_get_info(url):
import json
import urllib.request
import re
def between(start, end, string):
return re.findall(re.escape(start)+'(.*?)'+re.escape(end), string, flags=re.DOTALL)[0]
headers = {
"User-Agent": r"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0"
}
resp = urllib.request.urlopen(urllib.request.Request(url, headers=headers)).read().decode("UTF-8")
data = between('<script>window.cloudSettings =', ';</script>', resp).replace('/', r'\/')
data = re.sub(r'"[^"]+x3c.*?",', '"",', data)
return json.loads(data)
def cm_get_direct_link(url):
data = cm_get_info(url)
return "/".join([
data["dispatcher"]["weblink_get"][0]["url"],
data["request"]["weblink"]
])
direct_link = cm_get_direct_link("https://cloud.mail.ru/public/5poV/cRDxAbPEQ")
print(direct_link)
На момент 28.01.2022 работает.