Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # webbrowser_google_images_demo.py
- from urllib import quote
- import webbrowser
- base_url = "https://www.google.ca/search?q="
- image_default = "&newwindow=1&tbm=isch&source=lnt&tbs=isz:l&sa=X&ei=ZZZQVZZZZZZZyZZZZZGIDQ&ved=0CBQQpwU&dpr=1&biw=1368&bih=632"
- def verify(yn):
- while 1:
- if yn in ['y','yes']:
- return True
- elif yn in ['n','no']:
- return False
- yn = raw_input('Unverified Command. Please Answer with a Yes or No: ')
- def googleimagesearch():
- query = raw_input("Please enter your search query: ")
- yn = raw_input("Would you like that search to be in quotes? ")
- if verify(yn):
- query='"'+query+'"'
- yn = raw_input("Would you like your search to be 1280 width and 800 height? ")
- if verify(yn):
- image_url = "&newwindow=1&biw=1368&bih=632&tbs=islt:xga,isz:ex,iszw:1280,iszh:800&tbm=isch&source=lnt"
- else:
- image_url = image_default
- yn = raw_input("Would you like to refine your search? ")
- if verify(yn):
- refine = raw_input("Refine: ")
- query+=' '+refine
- link = base_url + quote(query) + image_url
- webbrowser.open(link)
- yn = raw_input("Would you like to do another image search? ")
- if verify(yn):
- googleimagesearch()
- googleimagesearch()
Add Comment
Please, Sign In to add comment