Created
October 20, 2020 08:00
-
-
Save aemxn/7b294c1db0ed325dfb699d15bbfd38a1 to your computer and use it in GitHub Desktop.
Revisions
-
aemxn created this gist
Oct 20, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ import requests import shutil import time import time import threading def dl(): image_url = "https://p3.fgies.com/bucket-pnb/PNB-11.jpg" filename_jpeg = image_url.split("/")[-1] filename_ts = filename_jpeg.split(".")[0] named_tuple = time.localtime() time_string = time.strftime("%Y%m%d-%H%M%S", named_tuple) filename = filename_ts + "-" + time_string + ".jpg" r = requests.get(image_url, stream = True) if r.status_code == 200: r.raw.decode_content = True with open(filename,'wb') as f: shutil.copyfileobj(r.raw, f) print('Image sucessfully Downloaded: ', filename) else: print('Image Couldn\'t be retreived') while True: dl() time.sleep(120) # 120s = 2 minutes