Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

4chan Image Downloader [Python 2]

Enjoy ✌
Code
#4chan image downloader with thread-rechecking, gif inclusion/exclusion

from bs4 import BeautifulSoup
import urllib2
import time
import os


def imli(url, anim, timer, savepath):
    print "[*] I'll not die til thread is 404'ed :-)"
    count = 0
    while True:
        try:
            content = urllib2.urlopen(url)
        except urllib2.HTTPError, e:
            if e.code == 404:
                print "Oops...Thread 404'ed!"
                return
        board = url.split('/')[3]
        if board == 'b':
            folder = savepath + '/random/' + url.split('/')[-1]
        elif board == 'g':
            folder = savepath + '/technology/' + url.split('/')[-1]
        elif board == 'w':
            folder = savepath + '/animeWallpapers/' + url.split('/')[-1]
        elif board == 'wg':
            folder = savepath + '/wallpapers/' + url.split('/')[-1]
        elif board == 'g':
            folder = savepath + '/literature/' + url.split('/')[-1]
        else:
            folder = savepath + '/board/' + url.split('/')[-1]
        if not os.path.exists(folder):
            os.makedirs(folder)
        html = content.read()
        content.close()
        soup = BeautifulSoup(html)
        links = soup.findAll('a', {'class': 'fileThumb'})
        fimg = []
        for l in links:
            iu = 'http:' + l.get('href')
            if not anim:
                if iu.split('.')[-1].upper() != 'GIF':
                    fimg.append(iu)
            else:
                fimg.append(iu)
        for i in fimg:
            img = i.split('/')[-1]
            if not os.path.exists(folder + '/' + img):
                try:
                    iurl = urllib2.urlopen(i)
                    f = open(folder + '/' + img, 'wb')
                    meta = iurl.info()
                    size = int(meta.getheaders("Content-Length")[0]) / 1024
                    count += 1
                    print "%s -> %s : %s KB" % (count, img, size)
                    f.write(urllib2.urlopen(i).read())
                    f.close()
                except urllib2.HTTPError, e:
                    print "Image not found...Thread 404'ed?"
        time.sleep(timer)
    return


imli(raw_input('Enter thread url:'), False, 15, 'd:/4chan')
raw_input('~Press any key to exit~')
exit(0)
How does i t work?
I don't have python, Can someone interpret this in java?
(Jul 18, 2015 02:04 PM)BotnetSlave Wrote:  How does i t work?
I don't have python, Can someone interpret this in java?

Just download Python man it's free...
Any help appreciated BTC ~
1JiBi7CjHuFqcJXyceXWKPBBQHjGn2JMKu


Possibly Related Threads...
Thread / Author Replies Views Last Post
by hackdaywalkerApr 25, 2014 09:08 AM 8 555 Apr 25, 2014 09:08 AM
Last Post: SIMONBC
by LozabSep 27, 2013 10:42 AM 21 1,356 Sep 27, 2013 10:42 AM
Last Post: B0$$
by DosManiaOct 14, 2012 03:11 PM 11 1,150 Oct 14, 2012 03:11 PM
Last Post: galan530