Skip to content

Instantly share code, notes, and snippets.

@flashblaze
Last active November 16, 2019 07:18
Show Gist options
  • Select an option

  • Save flashblaze/eb4d660846c3c2381609bfbd51f8055f to your computer and use it in GitHub Desktop.

Select an option

Save flashblaze/eb4d660846c3c2381609bfbd51f8055f to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
url = 'https://stevenuniver.se/#season1'
r = requests.get(url)
soup = BeautifulSoup(r.content, 'html5lib')
video_links_with_tag = soup.find_all('source')
titles_with_tag = soup.find_all('h3')
titles_without_tag = []
for title in titles_with_tag:
titles_without_tag.append(title.contents[0])
video_links_without_tag = []
for video in video_links_with_tag:
video_links_without_tag.append(video['src'])
titles_and_video_links = list(zip(titles_without_tag, video_links_without_tag))
for title_and_video in titles_and_video_links:
r = requests.get(title_and_video[1])
file_name = title_and_video[0].replace('"', '') + '.mp4'
print("Donloading " + title_and_video[0].replace('"', ''))
with open(file_name, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024*1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
print("Done")
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment