1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[FREE] Tumblr Image Ripper - Python

Discussion in 'Black Hat SEO Tools' started by naughtynewell, Mar 31, 2016.

  1. naughtynewell

    naughtynewell Junior Member

    Joined:
    Mar 24, 2013
    Messages:
    138
    Likes Received:
    39
    I'm a python dev. I've written this script a million times, but figured that it'd be a good idea to share it with the community so that everyone can rip images off of tumblr whenever they want.

    If people enjoy this, I have similar rippers for Twitter & Reddit. I've also written a script that will turn a series of images into a slideshow video.

    For now, here's the Tumblr script:

    Code:
    [COLOR=#cc7832][B]from [/B][/COLOR]pytumblr [COLOR=#cc7832][B]import [/B][/COLOR]TumblrRestClient
    [COLOR=#cc7832][B]import [/B][/COLOR]os
    [COLOR=#cc7832][B]import [/B][/COLOR]requests
    [COLOR=#cc7832][B]import [/B][/COLOR]itertools
    [COLOR=#cc7832][B]from [/B][/COLOR]multiprocessing [COLOR=#cc7832][B]import [/B][/COLOR]Pool
    
    auth = #Get your auth credentials from http://tumblr.com/oauth/apps and https://github.com/tumblr/pytumblr/blob/master/interactive_console.py
    
    client = TumblrRestClient(auth[[COLOR=#6897bb]0[/COLOR]][COLOR=#cc7832], [/COLOR]auth[[COLOR=#6897bb]1[/COLOR]][COLOR=#cc7832], [/COLOR]auth[[COLOR=#6897bb]2[/COLOR]][COLOR=#cc7832], [/COLOR]auth[[COLOR=#6897bb]3[/COLOR]])
    
    tumblr = [COLOR=#a5c261]'NAME OF TUMBLR W/O .tumblr.com'
    [/COLOR][COLOR=#a5c261]
    [/COLOR]all_results = []
    
    
    [COLOR=#cc7832][B]def [/B][/COLOR][B]get_posts[/B](offset[COLOR=#cc7832], [/COLOR]blog):
        posts = client.posts(blog[COLOR=#cc7832], [/COLOR][COLOR=#aa4926]type[/COLOR]=[COLOR=#a5c261]'photo'[/COLOR][COLOR=#cc7832], [/COLOR][COLOR=#aa4926]offset[/COLOR]=offset)
        photos = []
        [COLOR=#cc7832][B]for [/B][/COLOR]post [COLOR=#cc7832][B]in [/B][/COLOR]posts[[COLOR=#a5c261]'posts'[/COLOR]]:
            [COLOR=#cc7832][B]for [/B][/COLOR]photo [COLOR=#cc7832][B]in [/B][/COLOR]post[[COLOR=#a5c261]'photos'[/COLOR]]:
                photos.append(photo[[COLOR=#a5c261]'original_size'[/COLOR]][[COLOR=#a5c261]'url'[/COLOR]])
        [COLOR=#cc7832][B]return [/B][/COLOR]photos
    
    
    [COLOR=#cc7832][B]def [/B][/COLOR][B]get_posts_star[/B](a_b):
        [COLOR=#cc7832][B]return [/B][/COLOR]get_posts(*a_b)
    
    
    [COLOR=#cc7832][B]def [/B][/COLOR][B]get_image[/B](image_url):
        filename = os.path.basename(image_url)
        r = requests.get(image_url)
        [COLOR=#cc7832][B]if [/B][/COLOR]r.status_code == [COLOR=#6897bb]200[/COLOR]:
            [COLOR=#cc7832][B]with [/B][/COLOR][COLOR=#8888c6]open[/COLOR](filename[COLOR=#cc7832], [/COLOR][COLOR=#a5c261]'wb'[/COLOR]) [COLOR=#cc7832][B]as [/B][/COLOR]f:
                [COLOR=#cc7832][B]for [/B][/COLOR]chunk [COLOR=#cc7832][B]in [/B][/COLOR]r.iter_content([COLOR=#6897bb]1024[/COLOR]):
                    f.write(chunk)
                f.close()
    
    [COLOR=#cc7832][B]if [/B][/COLOR]__name__ == [COLOR=#a5c261]'__main__'[/COLOR]:
        offsets = [x [COLOR=#cc7832][B]for [/B][/COLOR]x [COLOR=#cc7832][B]in [/B][/COLOR][COLOR=#8888c6]xrange[/COLOR](client.posts(tumblr[COLOR=#cc7832], [/COLOR][COLOR=#aa4926]type[/COLOR]=[COLOR=#a5c261]'photo'[/COLOR])[[COLOR=#a5c261]'total_posts'[/COLOR]]) [COLOR=#cc7832][B]if [/B][/COLOR]x % [COLOR=#6897bb]20 [/COLOR]== [COLOR=#6897bb]0[/COLOR]]
        pool = Pool([COLOR=#6897bb]25[/COLOR])
        results = pool.map_async(get_posts_star[COLOR=#cc7832], [/COLOR]itertools.izip(offsets[COLOR=#cc7832], [/COLOR]itertools.repeat(tumblr))).get([COLOR=#6897bb]99999[/COLOR])
        pool.close()
        pool.join()
        all_results = [x [COLOR=#cc7832][B]for [/B][/COLOR]url [COLOR=#cc7832][B]in [/B][/COLOR]results [COLOR=#cc7832][B]for [/B][/COLOR]x [COLOR=#cc7832][B]in [/B][/COLOR]url]
        pool = Pool([COLOR=#6897bb]25[/COLOR])
        pool.map_async(get_image[COLOR=#cc7832], [/COLOR]all_results).get([COLOR=#6897bb]9999999[/COLOR])
        pool.close()
        pool.join()
    
    If you have any issues with this, let me know and I'll see if I can help you out.

    NN.
     
  2. TheMossad

    TheMossad Registered Member

    Joined:
    Mar 4, 2016
    Messages:
    79
    Likes Received:
    14
    How and where to run this?

    I'm a newbie to this kind of running code. So, help me out here
     
    • Thanks Thanks x 1