3

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

import requests

from bs4 import BeautifulSoup


import os

# Function to download video profile


def download_video(url, save_path):
with open(save_path, "wb") as file:
response = requests.get(url)
file.write(response.content)

# URL of the webpage containing video profiles


url = "https://example.com/profiles"

# Send a GET request to the URL


response = requests.get(url)

# Parse the HTML content using BeautifulSoup


soup = BeautifulSoup(response.text, "html.parser")

# Find all video profile links


video_links = [link["href"] for link in soup.find_all("a", href=True) if
link["href"].endswith(".mp4")]

# Create a directory to save downloaded videos


os.makedirs("downloaded_videos", exist_ok=True)

# Download all video profiles


for i, video_link in enumerate(video_links, start=1):
video_url = video_link # assuming the links are absolute
save_path = f"downloaded_videos/video_{i}.mp4"
download_video(video_url, save_path)
print(f"Downloaded video {i}")

print("All videos downloaded successfully.")

You might also like