Skip to content

Instantly share code, notes, and snippets.

@navinpai
Last active December 19, 2015 08:29
Show Gist options
  • Select an option

  • Save navinpai/5925737 to your computer and use it in GitHub Desktop.

Select an option

Save navinpai/5925737 to your computer and use it in GitHub Desktop.
Script to get all images from gags247.com. The site has open indexes. Open indexes are NEVER a good thing :|
from bs4 import BeautifulSoup
import requests
def getimages(parentlink):
for link in BeautifulSoup(requests.get(parentlink).text).find_all('a'):
if(link.get('href')[0]!='/'):
if(link.get('href')[-1]=='/'):
getimages(parentlink+link.get('href'))
else:
with open(link.get('href'), 'wb') as f:
for chunk in requests.get(parentlink+link.get('href')).iter_content():
f.write(chunk)
getimages('http://gags247.com/images/2013/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment