Skip to content

Commit

Permalink
final GUI based imageDownloader from pexels.com
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshlinux committed Apr 21, 2018
1 parent 8480d33 commit c68ee0c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions webscraper/imagedownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ def downloader(image_url,path):
file_name = random.randrange(1,10000)
full_file_name = os.path.join(path,str(file_name) + '.jpg')
#print(full_file_name)
urllib.request.urlretrieve(image_url,full_file_name)
r = requests.get(image_url, stream = True)
pdf = open(full_file_name,"wb")
for chunk in r.iter_content(chunk_size=1024):
# writing one chunk at a time to pdf file
if chunk:
pdf.write(chunk)
pdf.close()

if( len (sys.argv) > 1):
query = "+".join(sys.argv[1:])
Expand All @@ -33,8 +39,10 @@ def downloader(image_url,path):
name = link.get('srcset')
len = (name.find('?'))
newname = name[0:len]
#print(newname)
print(newname)
#webbrowser.open(newname)
downloader(newname,directory)
print("Download complete check your folder")
#root = tk.Tk()
#root.withdraw()
#directory = filedialog.askdirectory() #source folder
Expand Down

0 comments on commit c68ee0c

Please sign in to comment.