Created
March 25, 2020 20:57
-
-
Save davidsan/ee9f587d9c552dcc32c2bb155c369083 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
import urllib | |
import re | |
query = "apple juice" | |
q = re.sub(" ", "+", query) | |
url = 'https://www.google.com/search?q='+q+'&tbm=isch&gbv=1' | |
header = { | |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Firefox/68.0", | |
} | |
soup = BeautifulSoup(urllib.request.urlopen(urllib.request.Request(url, headers=header)), 'html.parser') | |
for img in soup.find_all("img", {"style": "border:1px solid #ccc;padding:1px"}): | |
print(img["src"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment