使用 Python 和 Selenium 抓取 YouTube 视频 [英] Scrape YouTube Videos with Python and Selenium
问题描述
我想为朋友从TVFilthyFrank"中抓取所有视频.我有他的每个视频的所有链接.我现在想测量所有视频的大小(以 MB 为单位)并下载它们.我知道我可以只说 driver.get(VIDEO_URL)
然后从播放器中取出 src 但这会花费很长时间而且看起来不太好.有没有办法从视频链接中获取视频源(或至少是视频的一些信息)?
I want to Scrape all Videos from 'TVFilthyFrank' for a friend. I have all links to every video of him.
I want to measure the size in MB for all videos now and download them.
I know I can just say driver.get(VIDEO_URL)
and then just get the src out of the player but that would take very long and wouldt look nice.
Is there anyway to get the video src (or at least some information to the vid) out of the video link ?
推荐答案
你应该试试 youtube-dl
: https://github.com/ytdl-org/youtube-dl.它可以在 python 代码中作为模块使用,也可以在 shell 中使用.
You should try youtube-dl
: https://github.com/ytdl-org/youtube-dl. It can be used in python code as modude and in shell.
要从 TVFilthyFrank 频道下载所有视频,您可以使用 youtube-dl -f bestvideo+bestaudio --write-info-json https://www.youtube.com/user/TVFilthyFrank
(-f bestvideo+bestaudio
表示最好的质量).--write-info-json
表示将元数据保存到 json 文件中.
To download all videos from channel TVFilthyFrank you can use youtube-dl -f bestvideo+bestaudio --write-info-json https://www.youtube.com/user/TVFilthyFrank
(-f bestvideo+bestaudio
means the best quality). --write-info-json
means save metadata to json file.
这篇关于使用 Python 和 Selenium 抓取 YouTube 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!