خرید بک لینک

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 tu a series of images into a slideshow video.

For now, here's the Tumblr script:

Code:

from pytumblr import TumblrRestClient
import os
import requests
import itertools
from multiprocessing import 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[0], auth[1], auth[2], auth[3])

tumblr = 'NAME OF TUMBLR W/O .tumblr.com'

all_results = []


def get_posts(offset, blog):
    posts = client.posts(blog, type='photo', offset=offset)
    photos = []
    for post in posts['posts']:
        for photo in post['photos']:
            photos.append(photo['original_size']['url'])
    retu photos


def get_posts_star(a_b):
    retu get_posts(*a_b)


def get_image(image_url):
    filename = os.path.basename(image_url)
    r = requests.get(image_url)
    if r.status_code == 200:
        with open(filename, 'wb') as f:
            for chunk in r.iter_content(1024):
                f.write(chunk)
            f.close()

if __name__ == '__main__':
    offsets = [x for x in xrange(client.posts(tumblr, type='photo')['total_posts']) if x % 20 == 0]
    pool = Pool(25)
    results = pool.map_async(get_posts_star, itertools.izip(offsets, itertools.repeat(tumblr))).get(99999)
    pool.close()
    pool.join()
    all_results = [x for url in results for x in url]
    pool = Pool(25)
    pool.map_async(get_image, all_results).get(9999999)
    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.

برچسب: نویسنده: کاوه محمدزادگان تاريخ: جمعه 13 فروردين 1395 ساعت: 6:53

صفحه بندی