MCPcopy Create free account
hub / github.com/geekcomputers/Python / search_for_image

Function search_for_image

Google_Image_Downloader/image_grapper.py:45–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43
44
45def search_for_image():
46 print("Enter data to download Images: ")
47 data = input()
48 search_query = {"q": data}
49 search = urlencode(search_query)
50 print(search)
51 g = GOOGLE_IMAGE + search
52 request = Request(g, headers=usr_agent)
53 r = urlopen(request).read()
54 sew = BeautifulSoup(r, "html.parser")
55 images = []
56
57 # print(sew.prettify())
58
59 results = sew.findAll("div", {"class": "rg_meta"})
60 for re in results:
61 (link, Type) = (json.loads(re.text)["ou"], json.loads(re.text)["ity"])
62 images.append(link)
63 counter = 0
64 for re in images:
65 rs = requests.get(re)
66 with open("img" + str(counter) + ".jpg", "wb") as file:
67 file.write(rs.content)
68
69 # urlretrieve(re, 'img' + str(count) + '.jpg')
70
71 counter += 1
72 return True
73
74
75def download_wallpapers_1080p():

Callers

nothing calls this directly

Calls 2

appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected