import requests
import urllib3
urllib3.disable_warnings()
import re
import json
import base64
cookie='你的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).text
pattern = 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_url
baseUrl='https://www.ixigua.com/6982369217265795599'
audio_url,video_url=getRealUrl(baseUrl)
print(audio_url)
print(video_url)
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://zhzhx.blog.csdn.net/article/details/118602356
内容来源于网络,如有侵权,请联系作者删除!