mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-30 15:31:10 +00:00
commit
ad76dd8a16
12
scripts/Image Scraper/README.md
Normal file
12
scripts/Image Scraper/README.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Image Scraper
|
||||
### Download images with a given url
|
||||
|
||||
This is a simple script that lets you download images from a list of urls
|
||||
|
||||
|
||||
#### Usage
|
||||
|
||||
* Clone the repo
|
||||
* change the urls in script.py
|
||||
* run python script.py
|
||||
|
26
scripts/Image Scraper/script.py
Normal file
26
scripts/Image Scraper/script.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
from email.mime import image
|
||||
import urllib.request
|
||||
import os
|
||||
|
||||
#You can replace the replace the urls links according to your needs
|
||||
urls = [
|
||||
'https://images.unsplash.com/photo-1664552399245-8ee5fa8eddd2?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=685&q=80',
|
||||
|
||||
'https://images.unsplash.com/photo-1664519803504-a8ed329d9381?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=735&q=80',
|
||||
|
||||
'https://images.unsplash.com/photo-1664361859625-07f20702b6c2?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1074&q=80'
|
||||
|
||||
]
|
||||
|
||||
# This function will create a images folder to save our images
|
||||
def downloadImage(image_urls):
|
||||
crtFileLocation = os.getcwd()
|
||||
os.makedirs('Images')
|
||||
|
||||
for x in range(0, len(image_urls)):
|
||||
filename = 'image_' + str(x) + '.png'
|
||||
print(f'downloading {x+1} out of {len(image_urls)} images')
|
||||
urllib.request.urlretrieve(image_urls[x], os.path.join(crtFileLocation, 'Images', filename))
|
||||
|
||||
downloadImage(urls)
|
||||
|
Loading…
Reference in New Issue
Block a user