Created
April 28, 2015 15:00
-
-
Save enkeboll/42b663f0ab98987ee214 to your computer and use it in GitHub Desktop.
Download all gifs from a thebos.co (TheBosco) gif page
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
import urllib2 | |
from os import path | |
from urlparse import urlsplit | |
dir = path.join(path.expanduser("~"),'Downloads') | |
url = "http://thebos.co/e/venmohq-celebration" | |
page = urllib2.urlopen(url).read() | |
soup = BeautifulSoup(page) | |
data = soup.findAll('div', attrs={'class':'event-tile-view'}) | |
for tag in data: | |
# slicing needed to cut off the '_180' from the filename | |
img_url = tag.find('img').attrs['raw'][:-8]+'.gif' | |
try: | |
image = urllib2.urlopen(img_url).read() | |
img_name = path.basename(urlsplit(img_url)[2]) | |
with open(path.join(dir, img_name),'wb') as f: | |
f.write(image) | |
print img_name | |
except: | |
print "error with file {}".format(img_url) | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment