2019年11月16日 星期六

2019年7月4日 星期四

[python爬蟲] pytube 抓Youtube影片

【Version】
Python 3.7
Anaconda 3Spyder 4



【開啟 Anaconda Prompt】





下載最新版本 pytube 9.5.1
pip install pytube





【Python Code】
from pytube import YouTube

yt=YouTube("https://www.youtube.com/watch?v=27ob2G3GUCQ")
print("下載Youtube影片\n 影片標題:"+yt.title)

GetVideo=yt.streams.filter(file_extension="mp4",resolution="720p").all()
print(GetVideo)
stream = GetVideo[0]
stream.download("c:\\tem1")





可成功將Youtube影片抓回本機!!