Skip to content

Instantly share code, notes, and snippets.

@enkeboll
Created April 28, 2015 15:00
Show Gist options
  • Save enkeboll/42b663f0ab98987ee214 to your computer and use it in GitHub Desktop.
Save enkeboll/42b663f0ab98987ee214 to your computer and use it in GitHub Desktop.
Download all gifs from a thebos.co (TheBosco) gif page
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