Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default 50 Images will be downloaded #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 16 additions & 6 deletions google-images.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,33 @@ def all_links(page):
page = page[end_content:]
return links



def download_images(links, search_keyword):

search_keyword = search_keyword.replace("%20","_")
directory = search_keyword+'/'


if not os.path.isdir(directory):
os.makedirs(directory)


choice = raw_input("Do you want to save the links? [y]/[n]: ")
if choice=='y' or choice=='Y':
#write all the links into a test file.
f = open('links.txt', 'a') #Open the text file called links.txt
f = open(directory +'links.txt', 'a') #Open the text file called links.txt
for link in links:
f.write(str(link))
f.write("\n")
f.close() #Close the file
num = raw_input("Enter number of images to download (max 100): ")
num = raw_input("Enter number of images to download (50 default): ")
if num == "":
num = 50
counter = 1
errors=0
search_keyword = search_keyword.replace("%20","_")
directory = search_keyword+'/'
if not os.path.isdir(directory):
os.makedirs(directory)


pbar = ProgressBar()
for link in pbar(links):
if counter<=int(num):
Expand Down