【问题标题】:Download the first video from any website in python用python从任何网站下载第一个视频
【发布时间】:2022-07-21 18:34:45
【问题描述】:

有没有办法在python中下载网站的视频视频(无论是mp4还是youtube嵌入)。

例如:

def download_video(url):
   #download the video

download_video("mywebiste.html")

【问题讨论】:

    标签: python web-scraping download mp4 scrape


    【解决方案1】:

    对不起,我无法评论,所以我将展示一个程序示例并提供link:

    # importing the module 
    from pytube import YouTube 
    
    # where to save 
    SAVE_PATH = "E:/" #to_do 
    
    # link of the video to be downloaded 
    link="https://www.youtube.com/watch?v=xWOoBJUqlbI"
    
    try: 
        # object creation using YouTube
        # which was imported in the beginning 
        yt = YouTube(link) 
    except: 
        print("Connection Error") #to handle exception 
    
    # filters out all the files with "mp4" extension 
    mp4files = yt.filter('mp4') 
    
    #to set the name of the file
    yt.set_filename('GeeksforGeeks Video')  
    
    # get the video with the extension and
    # resolution passed in the get() function 
    d_video = yt.get(mp4files[-1].extension,mp4files[-1].resolution) 
    try: 
        # downloading the video 
        d_video.download(SAVE_PATH) 
    except: 
        print("Some Error!") 
    print('Task Completed!') 
    

    【讨论】:

      猜你喜欢
      • 2018-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多