From f60a0bdbb81b826b7840f0d5b55c99ed47fef3d9 Mon Sep 17 00:00:00 2001 From: Niklas Lang Date: Thu, 26 Oct 2017 23:54:58 +0200 Subject: [PATCH 1/4] Create image_downloader.py This script loads all images off a website. --- image_downloader/image_downloader.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 image_downloader/image_downloader.py diff --git a/image_downloader/image_downloader.py b/image_downloader/image_downloader.py new file mode 100644 index 0000000..baad155 --- /dev/null +++ b/image_downloader/image_downloader.py @@ -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)) From 81f6840f8171afaf00ce15d682ef9f81ae196db8 Mon Sep 17 00:00:00 2001 From: Niklas Lang Date: Thu, 26 Oct 2017 23:56:22 +0200 Subject: [PATCH 2/4] Create README.md --- image_downloader/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 image_downloader/README.md diff --git a/image_downloader/README.md b/image_downloader/README.md new file mode 100644 index 0000000..62ad0e7 --- /dev/null +++ b/image_downloader/README.md @@ -0,0 +1,3 @@ +Image Donwloader + +With this script you can download all images off a webite url. From 717aec62c58bf88e2cc7c13c7cb70ac6728105bd Mon Sep 17 00:00:00 2001 From: Niklas Lang Date: Thu, 26 Oct 2017 23:56:48 +0200 Subject: [PATCH 3/4] Update README.md --- image_downloader/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image_downloader/README.md b/image_downloader/README.md index 62ad0e7..0a8aaf0 100644 --- a/image_downloader/README.md +++ b/image_downloader/README.md @@ -1,3 +1,3 @@ Image Donwloader -With this script you can download all images off a webite url. +With this script you can download all images off a webite. From 474af7e6de2589e49c0da02a17535e3318c50029 Mon Sep 17 00:00:00 2001 From: Niklas Lang Date: Thu, 26 Oct 2017 23:57:41 +0200 Subject: [PATCH 4/4] Update README.md --- image_downloader/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image_downloader/README.md b/image_downloader/README.md index 0a8aaf0..97e9476 100644 --- a/image_downloader/README.md +++ b/image_downloader/README.md @@ -1,3 +1,3 @@ -Image Donwloader +# Image Donwloader With this script you can download all images off a webite.