安妹晓得今天晚上
(哦不~确切说是明天凌晨0:00)
大家都要去看复仇者联盟4首映场
十年布局,巅峰一役
期待数年的漫威超级英雄电影——
《复仇者联盟 4:终局之战》
将于4月24日0点整在中国大陆院线首映
影片时长预计3小时,
效果最好的imax、杜比影院一票难求!
现在离首映还有不到5小时,为了减缓等待焦虑心情,
大家可以趁此好好回顾一下《复联》上部作品剧情
啊~那没有资源咋办?不用方!
安妹今天就给大家分享程序员私藏的爬虫神器
教你一条命令下载《复仇者联盟3:无限战争》
听说你学会了爬虫,并且成功使用 urllib2/requests/scrapy 下载了想要的视频和音乐,但你有听过一条命令就能完成视频和音乐的下载呢?来看看今天带给你们的神器— you-get 吧!
1.什么是 you-get
you-get 是一个小型的命令行程序,它提供便利的方式来下载网络上的媒体信息(视频,音频,图像)。you-get 目前支持的国内外网站有80 。国外的 youtube、twitter、instagram 等等都是它支持的网站,国内支持的网站也有很多,如:bilibili、豆瓣、斗鱼、腾讯视频、优酷、芒果tv、快手、抖音、爱奇艺、酷狗音乐、秒拍、音乐tai等等。最全的网站支持列表请见:https://github.com/soimort/you-get#supported-sites。
2.安装 you-get
想要安装 you-get,有以下依赖必须安装:
python3
ffmpeg(强烈推荐) or libav
(可选) rtmpdump
接下来在命令行中输入:
3.使用 you-get 下载视频
我们来演示下如何通过 you-get 下载视频,假如我们想要下载《复仇者联盟3:无限战争》的一个预告视频,地址为:
http://v.youku.com/v_show/id_xmzq2otmxmtq4na.html?spm=a2h0j.11185381.listitem_page1.5!10~a。
下载之前,我们可以使用 --info/-i 来查看所有可用画质与格式(注意:windows 平台需要将 url 外面的单引号换成双引号):
$ you-get -i 'http://v.youku.com/v_show/id_xmzq2otmxmtq4na.html?spm=a2h0j.11185381.listitem_page1.5!10~a'site: 优酷 (youku)title: 《复仇者联盟3:无限战争》北美正式预告片 十年布局,巅峰一役streams: # available quality and codecs [ default ] _________________________________ - format: mp4hd3v2 container: mp4 video-profile: 1080p size: 29.9 mib (31303414 bytes) m3u8_url: http://pl-ali.youku.com/playlist/m3u8?vid=xmzq2otmxmtq4na==&type=hd3&ups_client_netip=712c9e06&utid=g4t3ezhlgqicaxesngys76wa&ccode=0502&psid=888175f6a5e54e15240fc4ff2a5a9f36&duration=143&expire=18000&drm_type=1&drm_device=7&ups_ts=1525718303&onoff=0&encr=0&ups_key=014c8160e58f685bde0d49447edc5ae4 # download-with: you-get --format=mp4hd3v2 [url] - format: mp4hd2v2 container: mp4 video-profile: 超清 size: 17.2 mib (18035231 bytes) m3u8_url: http://pl-ali.youku.com/playlist/m3u8?vid=xmzq2otmxmtq4na==&type=hd2&ups_client_netip=712c9e06&utid=g4t3ezhlgqicaxesngys76wa&ccode=0502&psid=888175f6a5e54e15240fc4ff2a5a9f36&duration=143&expire=18000&drm_type=1&drm_device=7&ups_ts=1525718303&onoff=0&encr=0&ups_key=014c8160e58f685bde0d49447edc5ae4 # download-with: you-get --format=mp4hd2v2 [url] - format: mp4hd container: mp4 video-profile: 高清 size: 10.3 mib (10777046 bytes) m3u8_url: http://pl-ali.youku.com/playlist/m3u8?vid=xmzq2otmxmtq4na==&type=mp4&ups_client_netip=712c9e06&utid=g4t3ezhlgqicaxesngys76wa&ccode=0502&psid=888175f6a5e54e15240fc4ff2a5a9f36&duration=143&expire=18000&drm_type=1&drm_device=7&ups_ts=1525718303&onoff=0&encr=0&ups_key=014c8160e58f685bde0d49447edc5ae4 # download-with: you-get --format=mp4hd [url] - format: 3gphd container: mp4 video-profile: 渣清 size: 3.9 mib (4101529 bytes) m3u8_url: http://pl-ali.youku.com/playlist/m3u8?vid=xmzq2otmxmtq4na==&type=mp4&ups_client_netip=712c9e06&utid=g4t3ezhlgqicaxesngys76wa&ccode=0502&psid=888175f6a5e54e15240fc4ff2a5a9f36&duration=143&expire=18000&drm_type=1&drm_device=7&ups_ts=1525718303&onoff=0&encr=0&ups_key=014c8160e58f685bde0d49447edc5ae4 # download-with: you-get --format=3gphd [url] - format: mp4sd container: mp4 video-profile: 标清 size: 5.7 mib (6020728 bytes) m3u8_url: http://pl-ali.youku.com/playlist/m3u8?vid=xmzq2otmxmtq4na==&type=flv&ups_client_netip=712c9e06&utid=g4t3ezhlgqicaxesngys76wa&ccode=0502&psid=888175f6a5e54e15240fc4ff2a5a9f36&duration=143&expire=18000&drm_type=1&drm_device=7&ups_ts=1525718303&onoff=0&encr=0&ups_key=014c8160e58f685bde0d49447edc5ae4 # download-with: you-get --format=mp4sd [url] 标有default 为默认画质。如果想要默认的画质,则直接使用以下命令下载:
$ you-get 'http://v.youku.com/v_show/id_xmzq2otmxmtq4na.html?spm=a2h0j.11185381.listitem_page1.5!10~a'site: 优酷 (youku)title: 《复仇者联盟3:无限战争》北美正式预告片 十年布局,巅峰一役stream: - format: mp4hd3v2 container: mp4 video-profile: 1080p size: 29.9 mib (31303414 bytes) m3u8_url: http://pl-ali.youku.com/playlist/m3u8?vid=xmzq2otmxmtq4na==&type=hd3&ups_client_netip=712c9e06&utid=r4p3e1fqex4caxesngyfsvgy&ccode=0502&psid=269429bb15c9f3bc56d9ad545f0835ae&duration=143&expire=18000&drm_type=1&drm_device=7&ups_ts=1525718195&onoff=0&encr=0&ups_key=3b6bfec46adf4747c607ed4ab4b37cc3 # download-with: you-get --format=mp4hd3v2 [url]downloading 《复仇者联盟3:无限战争》北美正式预告片 十年布局,巅峰一役.mp4 ... 100% ( 29.9/ 29.9mb) ├████████████████████████████████████████┤[1/1] 7 mb/s 滑动查看右侧内容
如果想要下载标清画质,则可以根据提示 #download-with 使用以下命令来下载:
$ you-get --format=mp4sd 'http://v.youku.com/v_show/id_xmzq2otmxmtq4na.html?spm=a2h0j.11185381.listitem_page1.5!10~a'site: 优酷 (youku)title: 《复仇者联盟3:无限战争》北美正式预告片 十年布局,巅峰一役stream: - format: mp4sd container: mp4 video-profile: 标清 size: 5.7 mib (6020728 bytes) m3u8_url: http://pl-ali.youku.com/playlist/m3u8?vid=xmzq2otmxmtq4na==&type=flv&ups_client_netip=712c9e06&utid=x4t3ez7y/gucaxesnga8qoc7&ccode=0502&psid=a0f83cea8f1d12b44077eb789c32c7a0&duration=143&expire=18000&drm_type=1&drm_device=7&ups_ts=1525718475&onoff=0&encr=0&ups_key=fa6e8812bd282935a8f011e5316a3158 # download-with: you-get --format=mp4sd [url]downloading 《复仇者联盟3:无限战争》北美正式预告片 十年布局,巅峰一役.mp4 ... 100% ( 5.7/ 5.7mb) ├████████████████████████████████████████┤[1/1] 11 mb/s 下载完成后,我们来看下下载后的视频截图:


4.其他常用设置参数
除了最基本的下载功能之外,you-get 还有很多其他的参数。
使用 --force/-f 强行重下载. (注意: 将覆盖同名文件或临时文件!)
使用 --output-dir/-o 设定路径, --output-filename/-o 设定输出文件名
使用 --http-proxy/-x 为you-get设置http代理
如果需要登录以观看 (例如, 私密视频), 可能必须将浏览器cookie通过 --cookies/-c 加载入 you-get
更多关于 you-get 的使用方式请看:https://github.com/soimort/you-get。
- 本文技术内容 作者:weisongzhao -
看完是不是也想感叹一句:
太羡慕技术改变世界的程序员大大啦!
来国信安学it,技术大拿不再遥不可及~
下一个高薪程序员就是你!
2019 冲鸭!