Created
June 26, 2017 15:03
-
-
Save DemiKara/9061d8e59326e32711b1f64bcd6786c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
import requests | |
from PIL import Image | |
from io import BytesIO | |
search = input("Search for:") | |
params = {"q": search} | |
r = requests.get("http://www.bing.com/images/seach", params=params) | |
print("Check") | |
soup = BeautifulSoup(r.text, "html.parser") | |
links = soup.findAll("a", {"class": "thumb"}) | |
print("Check Check") | |
for item in links: | |
img_obj = requests.get(item.atrrs["href"]) | |
print("Getting", item.attrs["href"]) | |
title = item.attrs["href"].split("/")[-1] | |
img = Image.open(BytesIO(img_obj.content)) | |
img.save("./images/" + title, img.format) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment