Python Forum
Download mp4 files from an url
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Download mp4 files from an url
#3
You most look at what you first function return.
>>> get_video_links()[0]
'https://file-examples.com/index.php/sample-video-files/sample-mp4-files/https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4'
Dos that look like working download link?
The test is simple paste into browser as see what happens.

Here is fix for your first function then can try to figure how to download.
import requests
from bs4 import BeautifulSoup

def video_links(video_url):
    response = requests.get(video_url)
    soup = BeautifulSoup(response.content, 'html5lib')
    for url_link in soup.find_all(class_="text-right file-link"):
        yield url_link.a.get('href', 'Something went wrong')

def download_video_series(video_links):
    pass

if __name__ == '__main__':
    video_url = "https://file-examples.com/index.php/sample-video-files/sample-mp4-files/"
    for link in video_links(video_url):
        print(link)
Output:
https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4 https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_640_3MG.mp4 https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_1280_10MG.mp4 https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_1920_18MG.mp4
Also don't use the old sting formatting(%s) anymore.
print("Downloading file:%s" % file_name) 
# f-string
print(f"Downloading file: {file_name}")
Reply


Messages In This Thread
Download mp4 files from an url - by q988988 - Mar-07-2022, 05:14 AM
RE: Download mp4 files from an url - by ibreeden - Mar-07-2022, 09:03 AM
RE: Download mp4 files from an url - by snippsat - Mar-07-2022, 10:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Opinion: how should my scripts cache web download files? stevendaprano 0 736 Dec-17-2022, 12:19 AM
Last Post: stevendaprano
  How to download a list of files from FTP? schnarkle 0 1,017 Jun-21-2022, 10:35 PM
Last Post: schnarkle
  download with internet download manager coral_raha 0 2,972 Jul-18-2021, 03:11 PM
Last Post: coral_raha
  How can I download Python files from GitHub? bitcoin10mil 2 2,852 Aug-26-2020, 09:03 PM
Last Post: Axel_Erfurt
  Download multiple large json files at once halcynthis 0 2,793 Feb-14-2019, 08:41 AM
Last Post: halcynthis
  API to download files ahantge 1 2,687 Apr-13-2018, 08:55 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020