Jump to content

file download via link


Recommended Posts

I'm looking for an application that can download all image, video, and audio files of a specific link. In addition, a tool that can drill down a specified number of times. For example, i want to download all media types from a given link and then drill down one layer and download all media types from the link posted in the original link. I hope that makes sense. Thanks.

Link to comment
Share on other sites

  • 2 years later...
  • 4 months later...

If I wanted to do this, I'd use Python. Something like this;

import os
import requests
from bs4 import BeautifulSoup

def download_media(url, depth=0):
    # Set maximum depth
    if depth > 2:
    # Request the page content
    response = requests.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')
    # Create a directory for the current page's media
    page_dir = url.split('/')[-1]
    if page_dir == '':
        page_dir = 'index'
    if not os.path.exists(page_dir):
    # Download all images and videos
    for tag in soup.find_all(['img', 'video']):
        src = tag.get('src')
        if src is None:
        if 'http' not in src:
            src = url + src
        filename = src.split('/')[-1]
        filepath = os.path.join(page_dir, filename)
            response = requests.get(src)
            with open(filepath, 'wb') as f:
            print(f'Downloaded {filename} from {url}')
        except Exception as e:
            print(f'Error downloading {filename} from {url}: {e}')
    # Recursively download media from linked pages
    for link in soup.find_all('a'):
        href = link.get('href')
        if href is None:
        if 'http' not in href:
            href = url + href
        download_media(href, depth=depth+1)

if __name__ == '__main__':
    url = input('Enter a URL: ')

I used GPT to assist in writing the above. Prompts for a URL, then downloads media up to 3 levels deep.


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...