Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # Usage: 8c.py "http://www.8chan.co/*/res/*.html" "download/location"
- __author__ = 'Sixem'
- import sys
- from BeautifulSoup import BeautifulSoup
- import urllib2
- import re
- import math
- cmdargs = str(sys.argv)
- req = urllib2.Request(str(sys.argv[1]), headers={'User-Agent' : "Fozilla Mirefox"})
- html = urllib2.urlopen(req)
- soup = BeautifulSoup(html)
- imgs = soup.findAll("p", {"class":"fileinfo"})
- cimg = len(imgs)
- cc = 0
- print ("Found: %s images! Starting download." % cimg)
- for img in imgs:
- cc += 1
- i = (img.a['href'])
- req = urllib2.Request(i, headers={'User-Agent' : "Fozilla Mirefox"})
- u = urllib2.urlopen(req)
- print ("[%s] %s" % (("%s/%s" % (cc, cimg)), i))
- sFile = open(('%s/%s' % (str(sys.argv[2]), i.split('/')[-1])), 'w')
- sFile.write(u.read())
- sFile.close()
- print 'All done!'
Add Comment
Please, Sign In to add comment