85 lines
2.4 KiB
Plaintext
85 lines
2.4 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"https://v92-dy.ixigua.com/65e0f20a39ff8801b1a75cb13772f885/5f9b1f3e/video/tos/cn/tos-cn-ve-15/05235eb3a2bd4bf4b39c3e613312edb6/?a=1128&br=2649&bt=883&cr=0&cs=0&cv=1&dr=0&ds=6&er=&l=202010300259290101980670282B3A923F&lr=&mime_type=video_mp4&qs=0&rc=M3hkZjhmMzM7djMzN2kzM0ApaDxoZ2ZoNjs5Nzg3NzY5PGdgMzJhcGVvczFfLS0zLS9zczUyNTNgNjEuYTJhYzA2LjA6Yw%3D%3D&vl=&vr=\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import re\n",
|
|
"\n",
|
|
"import requests\n",
|
|
"\n",
|
|
"headers = {\n",
|
|
" 'User-Agent': 'User-Agent\", \"Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16D57 Version/12.0 Safari/604.1',\n",
|
|
"}\n",
|
|
"\n",
|
|
"url = 'https://v.douyin.com/J8X86mA/' # 抖音分享的链接,自行更改\n",
|
|
"response = requests.get(url, headers=headers)\n",
|
|
"\n",
|
|
"now_url = response.url\n",
|
|
"pat_item_ids = '/video/(.*?)/'\n",
|
|
"item_ids = re.compile(pat_item_ids, re.S).findall(now_url)\n",
|
|
"\n",
|
|
"pat_dytk = 'dytk: \"(.*?)\"'\n",
|
|
"dytk = re.compile(pat_dytk, re.S).findall(response.text)\n",
|
|
"\n",
|
|
"url = 'https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/'\n",
|
|
"params = {\n",
|
|
" 'item_ids': item_ids,\n",
|
|
" 'dytk': dytk\n",
|
|
"}\n",
|
|
"response = requests.get(url, headers=headers, params=params).json()\n",
|
|
"true_url = response['item_list'][0]['video']['play_addr']['url_list'][0]\n",
|
|
"true_url = true_url.replace('playwm','play')\n",
|
|
"response = requests.get(true_url, headers=headers)\n",
|
|
"true_url = response.url\n",
|
|
"print(true_url)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.7.4"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|