根据 savefrom条例

本实例及教程只用于学习交流用,权利归savefrom.net所有

0. 思路

使用python从savefrom平台上获取指定youtube视频下载链接进行下载,不过savefrom的数据是用javascript加密的,这也是难度所在

本教程主要介绍制作思路,下一篇会介绍制作python

本教程根据stakoverflow 回答制作

1.准备

i.savfrom.net

一个网站可以免费下载youtube视频

2. 探索并规划获取方式

i.总览

打开https://en.savefrom.net/1-youtube-video-downloader-4/可以看见页面主要就一个from表单输入框和提交按钮组成

ii. 获取该网页取到下载url的请求

在chrome或其他浏览器按F12打开开发者控制台,点开Network选项卡



接下来模拟正常的用户流程,在输入框输入一个youtube视频地址,比如这个https://www.youtube.com/watch?v=IjJmTeBSEzU,然后点击Download提交url获取下载url,然后我们可以发现下面已经出现了下载链接。然后我们在network选项卡内可以发现一个特殊的申请saveform.php(如果没发现可以多提交几次,就会发现每次提交都有这个请求或者看html里的form元素的src地址就是savform.php)



我们就可以确定关于下载链接会出现在这个请求的返回值内。

iii. 在本地获取请求

在本地用IDE的http工具或者python构建出post请求代码,笔者用的是pycharm的httpClient(按2下左Shift,然后输入Tools,然后回车进入菜单,然后点击httpClient下的第一个)



把请求里第二个headers的内容全部复制然后格式化然后构建post请求



然后把下面的formdata的参数也复制进来,记得和headers换行

POST https://en.savefrom.net/savefrom.php
cache-Control: no-cache
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br
accept-language: zh-CN,zh;q=0.9,en;q=0.8
content-type: application/x-www-form-urlencoded
cookie: lang=en; country=CN; uid=fd94a82a406a8dd4; sfHelperDist=72; reference=14; clickads-e2=90; poropellerAdsPush-e=63; promoBlock=64; helperWidget=92; helperBanner=42; framelessHdConverter=68; inpagePush2=68; popupInOutput=9; _ga=GA1.2.799702638.1610248969; _gid=GA1.2.628904587.1610248969; PHPSESSID=4aojkm49oj7h3de65pekqii337; x-requested-with=; PHPSESSUD=122fb7e10af37e23d99e896fd188744f; _gat_helperWidget=1; _gat_inpagePush2=1
origin: https://en.savefrom.net
pragma: no-cache
referer: https://en.savefrom.net/1-youtube-video-downloader-4/
sec-ch-ua: "Google Chrome";v="87", " Not;A Brand";v="99", "Chromium";v="87"
sec-ch-ua-mobile: ?0
sec-fetch-dest: iframe
sec-fetch-mode: navigate
sec-fetch-site: same-origin
sec-fetch-user: ?1
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 sf_url=https://www.youtube.com/watch?v=YPvtz1lHRiw&sf_submit=&new=1&lang=en&app=&country=cn&os=Windows&browser=Chrome

如果配置没错,这个时候你运行后会显示出和在浏览器里一样的结果,然后可以发现参数里的sf_url就是需要下载的youtube地址

iv.解析请求结果

把取到的结果保存在本地然后在浏览器打开保存的本地文件,然后弹出一个弹窗后会发现这个页面什么都没有,但其实如果你在console输入window会发现有很多变量和函数,其中就有我们需要的加密后的url和解密函数



经过弹窗提示我们可以发现是这个html的js发现了我们不在他的网站上然后删除了显示下载url的代码所以我们才什么都看不到,打开source选项卡或者用IDE打开源代码查看



扫一下这个源代码,我们可以看见一些加密解密函数,被加密的乱码信息,哈希对照表,和一些奇怪的赋值操作,如图



我们可以看见,js部分由一个大闭包组成

  • 第3行到第9行是声明函数
  • 第10行是给$b赋值this也就是window
  • 第11到第13行是赋值3个变量
  • 第14,15行是对变量执行一些操作,这个也是我们重点关注的,毕竟执行加密,解密方法只可能在这

第14,15行格式化后如下

this.$d = $d;
this.$a = $a;
this.$e = $e;
this.$k = $k;
this.$c = $c;
$c = _q($c);
$c = _b($c);
_m($b, $c);

去掉前5行没有意义的变量互换值,加密解密函数存在的范围就在最后3行

$c = _q($c);
$c = _b($c);
_m($b, $c);

然后开始一个个试

先在console里输入第一行



然后就出现了明文,所以我们就确定这个是我们需要的解密函数

接下来输入第二行



发现出现了和上面一模一样的明文,所以这个也是解密函数

接下来输入第三行

发现这个执行了那段代码,这个应该是执行函数,所以我们现在就找到了解密函数位于js部分的最后几行

v.解析解密后的结果

console里用解密函数解密出的结果复制出来会得到一个JavaScript脚本

(function(){
function del(){while(document.body.firstChild){document.body.removeChild(document.body.firstChild);}};
if(window.location.hostname.search(/(?:^|\.|@)(savefrom\.net|sfrom\.net|savefrom\.com\.au|51\.159\.57\.158|(?:fe\d*|test)-front\.sf-apps\.com)$/i) == -1)
{
alert('Please go to http://savefrom.net/ to get direct links');
del();
return;
} function showResult(){
var success = false;
try
{
var d = window.parent.document;
if(d && d.getElementById)
{
var e = d.getElementById('sf_result');
if(e && e.innerHTML)
{
window.parent.sf.finishRequest(true);;
e.innerHTML = '';
window.parent.sf.videoResult.show({"id":"YPvtz1lHRiw","cipher":false,"meta":{"title":"The Most Genius Plays in Football","source":"https:\/\/www.youtube.com\/watch?v=YPvtz1lHRiw","duration":"7:03","tags":"lionel messi,football tiki taka,football highlight,football team plays,kevin de bruyne,mesut \u00f6zil,paul pogba,cristiano ronaldo,adama traore,luka modric,toni kroos,andres iniesta,kylian mbappe,neymar jr,zlatan ibrahimovic,franck ribery,paulo dybala,philippe coutinho,robert lewandowski,barcelona,real madrid,liverpool,manchester city"},"thumb":"https:\/\/i.ytimg.com\/vi\/YPvtz1lHRiw\/hqdefault.jpg","itags":["18","22","133","134","135","136","137","140","160","242","243","244","247","248","249","250","251","278"],"video_quality":["1080","720","480","360","240","144"],"url":[{"url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=18&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&gir=yes&clen=35202709&ratebypass=yes&dur=423.137&lmt=1603720879883261&mt=1610277156&fvip=4&c=WEB&txp=5531422&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgN_iBsjO6zSiW9dcOYYExfjeVuy1YCXtWcKT0cz2kMcECIQCMre2rssbqkWdohk9K4Ej8B8r9gARVc0-kAHVqhV1teQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","name":"MP4","subname":"360","info_url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=18&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&gir=yes&clen=35202709&ratebypass=yes&dur=423.137&lmt=1603720879883261&mt=1610277156&fvip=4&c=WEB&txp=5531422&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgN_iBsjO6zSiW9dcOYYExfjeVuy1YCXtWcKT0cz2kMcECIQCMre2rssbqkWdohk9K4Ej8B8r9gARVc0-kAHVqhV1teQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"mp4","ext":"mp4","downloadable":false,"quality":"360","audio":false,"no_audio":false,"itag":"18","filesize":35202709,"attr":{"title":"video format: 360","class":""},"info_token":"0c41b67f74ccb97e50f2e64fe5f4625a"},{"url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=22&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&ratebypass=yes&dur=423.137&lmt=1603723118280830&mt=1610277156&fvip=4&c=WEB&txp=5535432&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgWg_KEKuXDFH-OcphoOxU2tjE9B0WnidilKpa-vtbmigCIQD-eJlhFHZMi1VzRYI_jh0RZaMiLkkXYWnwGM2TJp0bLA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D&title=The%20Most%20Genius%20Plays%20in%20Football","name":"MP4","subname":"720","info_url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=22&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&ratebypass=yes&dur=423.137&lmt=1603723118280830&mt=1610277156&fvip=4&c=WEB&txp=5535432&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgWg_KEKuXDFH-OcphoOxU2tjE9B0WnidilKpa-vtbmigCIQD-eJlhFHZMi1VzRYI_jh0RZaMiLkkXYWnwGM2TJp0bLA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"mp4","ext":"mp4","downloadable":true,"quality":"720","audio":false,"no_audio":false,"itag":"22","attr":{"title":"video format: 720","class":""},"info_token":"674fa89ee246148990b3f36e750a5d32"},{"url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=QmTnf2BHCkCLm1nUC3OlqIwF&gir=yes&clen=177708494&dur=422.999&lmt=1603723164407782&mt=1610277156&fvip=4&keepalive=yes&c=WEB&txp=5535432&n=TD5jnO4_esWW9m&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhANMFMA1ypwGQjiGT_DlqlYwfqcqu1IlKZGoCrdIqWmzHAiAyOJJHIzUBcMQ6WBeEnepV4UlD3TY6rGSNKBVSVhbpIQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","name":"MP4","subname":"1080","info_url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=QmTnf2BHCkCLm1nUC3OlqIwF&gir=yes&clen=177708494&dur=422.999&lmt=1603723164407782&mt=1610277156&fvip=4&keepalive=yes&c=WEB&txp=5535432&n=TD5jnO4_esWW9m&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhANMFMA1ypwGQjiGT_DlqlYwfqcqu1IlKZGoCrdIqWmzHAiAyOJJHIzUBcMQ6WBeEnepV4UlD3TY6rGSNKBVSVhbpIQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"mp4 dash","ext":"mp4","downloadable":false,"quality":"1080","audio":false,"no_audio":true,"itag":"137","filesize":177708494,"attr":{"title":"video format: 1080 (without audio)","class":"no-audio"},"info_token":"6816215e43020185bb429874c33f1f73"},{"url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=248&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fwebm&ns=QmTnf2BHCkCLm1nUC3OlqIwF&gir=yes&clen=117037047&dur=422.999&lmt=1603725149388225&mt=1610277156&fvip=4&keepalive=yes&c=WEB&txp=5535432&n=TD5jnO4_esWW9m&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhANFyBfTGjhDMawSTzN1NjLLYLztYc8e6w3lXVXY5ldbxAiEA-UBT6Yb33Sr0Yhan0x9xlf1xVWFH-wu_y2HsgWkiuXo%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","name":"WEBM","subname":"1080","info_url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=248&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fwebm&ns=QmTnf2BHCkCLm1nUC3OlqIwF&gir=yes&clen=117037047&dur=422.999&lmt=1603725149388225&mt=1610277156&fvip=4&keepalive=yes&c=WEB&txp=5535432&n=TD5jnO4_esWW9m&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhANFyBfTGjhDMawSTzN1NjLLYLztYc8e6w3lXVXY5ldbxAiEA-UBT6Yb33Sr0Yhan0x9xlf1xVWFH-wu_y2HsgWkiuXo%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"webm dash","ext":"webm","downloadable":false,"quality":"1080","audio":false,"no_audio":true,"itag":"248","filesize":117037047,"attr":{"title":"video format: 1080 (without audio)","class":"no-audio"},"info_token":"43e803aa40437c9930975615121cc2c5"}],"hosting":101,"srv":"s30","sd":null,"hd":null});;
window.parent.sf.enableElement('sf_submit', true);
success=true;
}
}
}
catch(err){} del();
if(!success)
{
var alt = '';
if(alt) alert(alt);
}
} try {
if (typeof navigator.permissions != 'undefined') {
navigator.permissions.query({name:'notifications'}).then(function(permissionStatus) {
if(Notification.permission === 'denied' && permissionStatus.state === 'prompt') {
} else {
showResult();
}
});
} else {
showResult();
}
}
catch (err) {
showResult();
}
})();

我们可以发现里面有个del()删除函数,这就是为什么我们看不到这一段代码在执行后

因为被window.location.hostname.search(/(?:^|\.|@)(savefrom\.net|sfrom\.net|savefrom\.com\.au|51\.159\.57\.158|(?:fe\d*|test)-front\.sf-apps\.com)$/i) == -1检查出不是在他的网站上跑的所以就执行弹窗和del()把解密后的东西删除了

仔细检查这段代码可以发现这一行

window.parent.sf.videoResult.show({"id":"YPvtz1lHRiw","cipher":false,"meta":{"title":"The Most Genius Plays in Football","source":"https:\/\/www.youtube.com\/watch?v=YPvtz1lHRiw","duration":"7:03","tags":"lionel messi,football tiki taka,football highlight,football team plays,kevin de bruyne,mesut \u00f6zil,paul pogba,cristiano ronaldo,adama traore,luka modric,toni kroos,andres iniesta,kylian mbappe,neymar jr,zlatan ibrahimovic,franck ribery,paulo dybala,philippe coutinho,robert lewandowski,barcelona,real madrid,liverpool,manchester city"},"thumb":"https:\/\/i.ytimg.com\/vi\/YPvtz1lHRiw\/hqdefault.jpg","itags":["18","22","133","134","135","136","137","140","160","242","243","244","247","248","249","250","251","278"],"video_quality":["1080","720","480","360","240","144"],"url":[{"url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=18&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&gir=yes&clen=35202709&ratebypass=yes&dur=423.137&lmt=1603720879883261&mt=1610277156&fvip=4&c=WEB&txp=5531422&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgN_iBsjO6zSiW9dcOYYExfjeVuy1YCXtWcKT0cz2kMcECIQCMre2rssbqkWdohk9K4Ej8B8r9gARVc0-kAHVqhV1teQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","name":"MP4","subname":"360","info_url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=18&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&gir=yes&clen=35202709&ratebypass=yes&dur=423.137&lmt=1603720879883261&mt=1610277156&fvip=4&c=WEB&txp=5531422&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgN_iBsjO6zSiW9dcOYYExfjeVuy1YCXtWcKT0cz2kMcECIQCMre2rssbqkWdohk9K4Ej8B8r9gARVc0-kAHVqhV1teQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"mp4","ext":"mp4","downloadable":false,"quality":"360","audio":false,"no_audio":false,"itag":"18","filesize":35202709,"attr":{"title":"video format: 360","class":""},"info_token":"0c41b67f74ccb97e50f2e64fe5f4625a"},{"url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=22&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&ratebypass=yes&dur=423.137&lmt=1603723118280830&mt=1610277156&fvip=4&c=WEB&txp=5535432&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgWg_KEKuXDFH-OcphoOxU2tjE9B0WnidilKpa-vtbmigCIQD-eJlhFHZMi1VzRYI_jh0RZaMiLkkXYWnwGM2TJp0bLA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D&title=The%20Most%20Genius%20Plays%20in%20Football","name":"MP4","subname":"720","info_url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=22&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=H2IuXFgrekwcd2kUgtraypIF&ratebypass=yes&dur=423.137&lmt=1603723118280830&mt=1610277156&fvip=4&c=WEB&txp=5535432&n=9544-WEiIwBMq_&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cratebypass%2Cdur%2Clmt&sig=AOq0QJ8wRQIgWg_KEKuXDFH-OcphoOxU2tjE9B0WnidilKpa-vtbmigCIQD-eJlhFHZMi1VzRYI_jh0RZaMiLkkXYWnwGM2TJp0bLA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"mp4","ext":"mp4","downloadable":true,"quality":"720","audio":false,"no_audio":false,"itag":"22","attr":{"title":"video format: 720","class":""},"info_token":"674fa89ee246148990b3f36e750a5d32"},{"url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=QmTnf2BHCkCLm1nUC3OlqIwF&gir=yes&clen=177708494&dur=422.999&lmt=1603723164407782&mt=1610277156&fvip=4&keepalive=yes&c=WEB&txp=5535432&n=TD5jnO4_esWW9m&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhANMFMA1ypwGQjiGT_DlqlYwfqcqu1IlKZGoCrdIqWmzHAiAyOJJHIzUBcMQ6WBeEnepV4UlD3TY6rGSNKBVSVhbpIQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","name":"MP4","subname":"1080","info_url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=137&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fmp4&ns=QmTnf2BHCkCLm1nUC3OlqIwF&gir=yes&clen=177708494&dur=422.999&lmt=1603723164407782&mt=1610277156&fvip=4&keepalive=yes&c=WEB&txp=5535432&n=TD5jnO4_esWW9m&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIhANMFMA1ypwGQjiGT_DlqlYwfqcqu1IlKZGoCrdIqWmzHAiAyOJJHIzUBcMQ6WBeEnepV4UlD3TY6rGSNKBVSVhbpIQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"mp4 dash","ext":"mp4","downloadable":false,"quality":"1080","audio":false,"no_audio":true,"itag":"137","filesize":177708494,"attr":{"title":"video format: 1080 (without audio)","class":"no-audio"},"info_token":"6816215e43020185bb429874c33f1f73"},{"url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=248&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fwebm&ns=QmTnf2BHCkCLm1nUC3OlqIwF&gir=yes&clen=117037047&dur=422.999&lmt=1603725149388225&mt=1610277156&fvip=4&keepalive=yes&c=WEB&txp=5535432&n=TD5jnO4_esWW9m&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhANFyBfTGjhDMawSTzN1NjLLYLztYc8e6w3lXVXY5ldbxAiEA-UBT6Yb33Sr0Yhan0x9xlf1xVWFH-wu_y2HsgWkiuXo%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","name":"WEBM","subname":"1080","info_url":"https:\/\/r4---sn-25glene7.googlevideo.com\/videoplayback?expire=1610299253&ei=FeP6X7qLJvesxN8PteeBaA&ip=154.72.187.26&id=o-AFTOjos_M4e5ymyJ3pa8Zs6JxHQohnez1oxdyfxNGuFl&itag=248&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mh=nS&mm=31%2C29&mn=sn-25glene7%2Csn-25ge7nzs&ms=au%2Crdu&mv=m&mvi=4&pl=20&initcwndbps=182500&vprv=1&mime=video%2Fwebm&ns=QmTnf2BHCkCLm1nUC3OlqIwF&gir=yes&clen=117037047&dur=422.999&lmt=1603725149388225&mt=1610277156&fvip=4&keepalive=yes&c=WEB&txp=5535432&n=TD5jnO4_esWW9m&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhANFyBfTGjhDMawSTzN1NjLLYLztYc8e6w3lXVXY5ldbxAiEA-UBT6Yb33Sr0Yhan0x9xlf1xVWFH-wu_y2HsgWkiuXo%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhALlbQJhLhsKk9tVJdpd0OfXwuiWC26m4cDjWZ8MvxO1MAiEA8EG4gFtyQVAWXRWz_d3DYsCTY4oCiTobXSHKnemPR38%3D","type":"webm dash","ext":"webm","downloadable":false,"quality":"1080","audio":false,"no_audio":true,"itag":"248","filesize":117037047,"attr":{"title":"video format: 1080 (without audio)","class":"no-audio"},"info_token":"43e803aa40437c9930975615121cc2c5"}],"hosting":101,"srv":"s30","sd":null,"hd":null});;

这里面有一长串json文本然后里面就包含我们要的下载链接和其他杂七杂八的东西,在json格式化平台(比如bejson)把这一段json文本输入



可以发现meta主要是视频消息,然后url下就是不同分辨率的视频下载链接了

下一章会讲怎么制作自动python程序

-EOF-

用python做youtube自动化下载器 思路的更多相关文章

  1. 用python做youtube自动化下载器 代码

    目录 项目地址 思路 流程 1. post i. 先把post中的headers格式化 ii.然后把参数也格式化 iii. 最后再执行requests库的post请求 iv. 封装成一个函数 2. 调 ...

  2. Python实现多线程HTTP下载器

    本文将介绍使用Python编写多线程HTTP下载器,并生成.exe可执行文件. 环境:windows/Linux + Python2.7.x 单线程 在介绍多线程之前首先介绍单线程.编写单线程的思路为 ...

  3. 使用appium+python做UI自动化的demo

    使用appium+python做UI自动化的demo 案例使用的知乎app,下载最新的知乎apk,存在了电脑上,只需要配置本机上app目录,不需要再配置appPackage和appActivity # ...

  4. python多进程断点续传分片下载器

    python多进程断点续传分片下载器 标签:python 下载器 多进程 因为爬虫要用到下载器,但是直接用urllib下载很慢,所以找了很久终于找到一个让我欣喜的下载器.他能够断点续传分片下载,极大提 ...

  5. python的内置下载器

    python有个内置下载器,有时候在内部提供文件下载很好用. 进入提供下载的目录 # ls abc.aaa chpw.py finance.py lsdir.py ping.py u2d-partia ...

  6. Qt+Python开发百度图片下载器

    一.资源下载地址 https://www.aliyundrive.com/s/jBU2wBS8poH 本项目路径:项目->收费->百度图片下载器(可试用5分钟) 安装包直接下载地址:htt ...

  7. iOS开发——下载器的功能基本实现

    今天,做了一个下载器的Demo,即从本地配置的Apache服务器上,下载指定的文件.这次,我们下载服务器根目录下的html.mp4文件. 按照惯例,我们先创建一个URL对象和请求. NSURL *ur ...

  8. 【图文详解】python爬虫实战——5分钟做个图片自动下载器

    python爬虫实战——图片自动下载器 之前介绍了那么多基本知识[Python爬虫]入门知识,(没看的先去看!!)大家也估计手痒了.想要实际做个小东西来看看,毕竟: talk is cheap sho ...

  9. python爬虫实战——5分钟做个图片自动下载器

      python爬虫实战——图片自动下载器 制作爬虫的基本步骤 顺便通过这个小例子,可以掌握一些有关制作爬虫的基本的步骤. 一般来说,制作一个爬虫需要分以下几个步骤: 分析需求(对,需求分析非常重要, ...

随机推荐

  1. SQL数据库优化的六种方法

    SQL命令因为语法简单.操作高效受到了很多用户的欢迎.但是,SQL命令的效率受到不同的数据库功能的限制,特别是在计算时间方面,再加上语言的高效率也不意味着优化会更容易,所以每个数据库都需要依据实际情况 ...

  2. Linux内核源码分析之setup_arch (二)

    1. 概述 接着上一篇<Linux内核源码分析之setup_arch (一)>继续分析,本文首先分析arm_memblock_init函数,然后分析内核启动阶段的是如何进行内存管理的. 2 ...

  3. jQuery无限滚动

    由于demo实在虚拟桌面写的,所以懒得在敲一遍了,直接贴图了

  4. 膜 zhouakngyang 宝典

    持续更新! 注意:本文无 F12. about 周老师:怎么这么强! ZAKY 打 CF 大图:zaky cgr rk1 大图:zaky 传奇 \(1\) ZAKY 打 ATC ZAKY 切题

  5. mp4文件导致迅雷监视下载问题

    原因:没有为mp4设置响应的mime Type,默认就是附件的形式. 应该为其设置mime type类型  video/mp4 <staticContent> <mimeMap fi ...

  6. VMware 虚拟机网卡设置与外网访问

    1 查看虚拟机网卡设置,查看虚拟机网关. 2 然后,设置本地机器VMnet8网卡的IP地址和子网掩码.切记,IP地址不能与虚拟机网卡IP地址相同. 3 配置虚拟机Centos的ens33网卡 TYPE ...

  7. 2020-2021-1 20209307 《Linux内核原理与分析》第九周作业

    这个作业属于哪个课程 <2020-2021-1Linux内核原理与分析)> 这个作业要求在哪里 <2020-2021-1Linux内核原理与分析第九周作业> 这个作业的目标 & ...

  8. 基于excel实现接口自动化测试

    本文档介绍如何使用excel管理接口测试用例并一键执行的实现方式,其中包括 python 读写excel, request库的基本操作,接口用例的设计 接口用例设计 用例字段描述 被依赖表达式: 示例 ...

  9. numpy和pandas-数据分析模块

    应用:1.数据分析 2.深度学习 3.机器学习 运算速度快:numpy 和 pandas 都是采用 C 语言编写, pandas 又是基于 numpy, 是 numpy 的升级版本. 消耗资源少:采用 ...

  10. 网络知识扫盲——DNS

    参考文章链接  : https://baijiahao.baidu.com/s?id=1668393227924896391&wfr=spider&for=pc 一.DNS 是什么? ...