Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions image_downloader/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
# Image Donwloader

With this script you can download all images off a webite.
24 changes: 24 additions & 0 deletions image_downloader/image_downloader.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
"""This script loads all images of a website."""

import mimetypes
import requests
from bs4 import BeautifulSoup

while True:
try:
url = input("Your Website:")
website = requests.get(url)
break
except:
print("I can't open the website!")
html = BeautifulSoup(website.text, "html.parser")
images = html.find_all("img")

def download(url, filename):
file_url = requests.get(url)
file_extension = mimetypes.guess_extension(file_url.headers['content-type'])
with open(filename+file_extension, 'wb') as file:
file.write(file_url.content)

for index, image in enumerate(images):
download(image["src"], "image{index}".format(index=index))