Last active
December 19, 2015 08:29
-
-
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 :|
This file contains hidden or 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
| 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