chevron_left chevron_right
Login Register invert_colors photo_library

Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average

Google Image search program filter_list
Google Image search program #1
Run down
Searches google for images, then automatically opens them in your browser.


import webbrowser,re,urllib,urllib.request,sys,random,time

if sys.version_info[0] > 2:
    import urllib.request as urlreq
    import urllib2 as urlreq

def googleimagesearch():
        search = input("What image should we look up? ")
        gdata = urlreq.urlopen("" % "+".join(search))
        xdat =
        x = re.finditer('"unescapedUrl":"(.+?)","url":"', xdat)
        mes = []
        for m in x:
            m = str(
        link = random.choice(mes)
        link = link.replace("https","http")'%s' % link)
        nxt = input("Would you like to search another image? ")
        if nxt == "yes":
        elif nxt == "no":
            print("Unknown command, auto restarting."),time.sleep(1),googleimagesearch()
    except Exception as e:
        print("\n%s\n" % e)


With x = re.finditer('"unescapedUrl":"(.+?)","url":"', xdat), we use regex to find the unescapedUrl with a plus in it. We then create a list using mes = [] and add a links found with the regex into it.

Hope you liked what I coded/programmed. Have sex with it, give it a hickey, just enjoy it.


Users browsing this thread: 1 Guest(s)