一、西瓜视频网址解析完整代码:
import requests
import urllib3
urllib3.disable_warnings()
import re
import json
import base64cookie='你的cookie'
headers={"user-agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36","cookie":cookie
}def getRealUrl(url):response = requests.get(url, verify=False, headers=headers).textpattern = re.compile('(?<=window._SSR_HYDRATED_DATA=).*?(?=</script>)')jsonResult = pattern.findall(response)[0]print(jsonResult)jsonResult = jsonResult.replace(':undefined', ':"undefined"')jsonData = json.loads(jsonResult)print(jsonResult)infor=jsonData['anyVideo']['gidInformation']['packerData']['video']dash=infor['videoResource']['dash']if 'dynamic_video' in dash.keys():audioUrl=dash['dynamic_video']['dynamic_audio_list'][0]['main_url']videoUrl=dash['dynamic_video']['dynamic_video_list'][0]['main_url']else:print('未获取到源地址')audio_url = base64.b64decode(audioUrl).decode("utf-8")video_url = base64.b64decode(videoUrl).decode("utf-8")return audio_url,video_urlbaseUrl='https://www.ixigua.com/6982369217265795599'
audio_url,video_url=getRealUrl(baseUrl)
print(audio_url)
print(video_url)
二、获取到video_url:
http://v9-xg-web-s.ixigua.com/3a2c466210265d6cf4ca0e0510e45ed6/60e7d08f/video/tos/cn/tos-cn-v-0026/0efdad4b6e844b2294d1d9ec1b0e1717/media-video-avc1/?a=1768&br=403&bt=403&cd=0%7C0%7C0&ch=0&cr=0&cs=0&cv=1&dr=0&ds=1&er=0&l=02162580032858000000000000000000000ffff0a966beb56ac73&lr=default&mime_type=video_mp4&net=0&pl=0&qs=0&rc=anZycGk6Zmw5NjMzNGQzM0ApNGU8ZWU4NmQ7NzxnOjw1aGcuNmwucjRfNWdgLS1kLi9zcy9hLjNfYGBgNGMvMmMzNTM6Yw%3D%3D&vl=&vr=
三、利用工具IDM下载: