Skip to content

Instantly share code, notes, and snippets.

@twhite96
Last active June 19, 2016 04:15
Show Gist options
  • Save twhite96/622d5aed4018f77e7efe0be1f6e15395 to your computer and use it in GitHub Desktop.
Save twhite96/622d5aed4018f77e7efe0be1f6e15395 to your computer and use it in GitHub Desktop.
Web Image Scraper
import urllib2
resp = urllib2.urlopen('http://testurl.com')
from bs4 import BeautifulSoup
soup = BeautifulSoup(resp.read())
images = soup.find_all('img')
foreach images in image:
filename = image.get('src');
data = urllib2.urlopen(filename).read();
with open("myfile.jpeg", "wb") as code:
code.write(data);
@twhite96
Copy link
Author

twhite96 commented Jun 17, 2016

Need BeautifulSoup library. pip install beautifulsoup4. Make sure to update pip before installing. For Python 2.6-3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment