Skip to content

Instantly share code, notes, and snippets.

@karngyan
Created November 12, 2019 13:10
Show Gist options
  • Save karngyan/98fa49ce9f34b13c32d049b4622d23bc to your computer and use it in GitHub Desktop.
Save karngyan/98fa49ce9f34b13c32d049b4622d23bc to your computer and use it in GitHub Desktop.
import requests, bs4, sys
base_url = "https://www.google.com"
r = requests.get(base_url)
soup = bs4.BeautifulSoup(r.text)
img = soup.select('img')[0]
image_url = img.get('src')
url = base_url + image_url
rm = requests.get(url)
file = open("/home/google.png", "wb")
for chunk in rm.iter_content(10**5):
file.write(chunk)
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment