Skip to content

Instantly share code, notes, and snippets.

@nickedes
Created September 21, 2014 14:20
Show Gist options
  • Save nickedes/972605b2656f0234e7f0 to your computer and use it in GitHub Desktop.
Save nickedes/972605b2656f0234e7f0 to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
import hashlib
def getPic(search):
#replace spaces by %20 for searching
search = search.replace(" ","%20")
url = "https://www.google.com/search?site=imghp&tbm=isch&source=hp&biw=1414&bih=709&q="+search+"&oq="+search
r = requests.get(url)
data = r.text
soup = BeautifulSoup(data)
results = soup.findAll("img")
for r in results:
print "%(src)s" % r
getPic("cars and music")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment