Advertisement
thinkJD

Untitled

Jul 28th, 2014
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. # ----------------------------------------------------------------------------
  2. # "THE BEER-WARE LICENSE" (Revision 42):
  3. # <jd.georgens@gmail.com> wrote this file. As long as you retain this notice you
  4. # can do whatever you want with this stuff. If we meet some day, and you think
  5. # this stuff is worth it, you can buy me a beer in return Jan-Daniel Georgens
  6. # ----------------------------------------------------------------------------
  7.  
  8. from BeautifulSoup import BeautifulSoup
  9. import urllib2
  10. import urllib
  11. import os.path
  12.  
  13. endpoint = 'http://users.gifme.io/u/b6cfd'
  14. base_path = os.path.dirname(os.path.realpath(__file__))
  15. save_path = os.path.join(base_path, 'gifs/')
  16. soup = BeautifulSoup(urllib2.urlopen(endpoint).read())
  17. imgs = list()
  18.  
  19. for link in soup.findAll('img'):
  20.     imgs.append(link.get('src'))
  21.  
  22. for img in imgs:
  23.     urllib.urlretrieve(img, os.path.join(save_path, os.path.join(save_path, os.path.basename(img))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement