Devilzc0de Forum Follow @devilzc0de
  • Home
  • Hacking
  • Networking
  • Programming
  • O.S
  • Server
  • Tweets
  • Search
  • Member List
  • Calendar
Current time: 05-22-2013, 03:30 AM Hello There, Guest! (Login — Register)
Devilzc0de Forum › Information Technology › Programming › Python v
« Previous 1 2 3 4 Next »

Script untuk download semua gambar dari tumblr

Home General Computer Multimedia Business Lounge

Pages (3): 1 2 3 Next »
Post Reply 
Tweet
Threaded Mode | Linear Mode
Script untuk download semua gambar dari tumblr
01-13-2012, 05:40 PM (This post was last modified: 01-13-2012 07:37 PM by ketek.)
Post: #1
ketek Offline
bocah ingusan
*******
Administrators
Posts: 2,168
Joined: Jan 2010
Reputation: 369
Star Script untuk download semua gambar dari tumblr
Salam Dcers

ane kemaren lagi jalan2 truz nemu website yg gambarnya bagus2 di tumblr... (bb++) ngakak

truz ane pengen download satu2 tuh males banget :
- klik kanan di gambar, save as
- klik kanan di pages, save page as
truz berkali-kali kan ane pegel..

langsung ane googling, eh dapet program ini
http://sourceforge.net/projects/gettumblrpic/
[Image: 306883]

lumayan sih, cuman ribet banget, dia cuma ngambilin link2 ke gambarnya aja, gak langsung ke save, akhirnya ane buat sendiri ae scriptnya...

ini dia scriptnya... (tumblr.py) update versi 0.2 lumayan stabil, monggo
Code:
#!/usr/bin/env python
#
#    This script will download all images from given tumblr website
#   Devilzc0de(c) 2012
#
#
import urllib
import urllib2
import sys
import os
import re
from math import fabs

pageStart = 1
pageEnd = 999
pageNum = 1
failed_counter = 0
last_page = ''
ver = '0.2'

def get_link(siteName):
    global pageNum, failed_counter, last_page

    html_url = 'http://' + siteName + '.tumblr.com/page/' + str(pageNum)
    print('[+] page\t: ' + html_url)
    html_page = get_file(html_url)
    
    num_images = get_images(siteName, html_page)
    
    if num_images == 0:
        failed_counter += 1
    if fabs(len(html_page) - len(last_page)) <= 13:
        failed_counter += 1
    if failed_counter == 3:
        create_index_html(siteName)
        print('[-] exit\t: ' + str(failed_counter) + ' pages without images')
        raise SystemExit
    last_page = html_page
    pageNum +=1
    

def get_images(siteName, html_page):
    global failed_counter
    mObj = re.findall(r'<img([^>]*)src=\"([^\"]*)\"([^>]*)>', html_page)    
    count = 0
    if mObj:
        for i in mObj:
            img = i[1]
            # avatar_394f5be4958e_40.png
            if not re.match(r'.*avatar_[a-fA-F0-9]{12}_.*', img):
                save_file(siteName, img)
                count += 1
    else:
        failed_counter += 1
    return count
        
def save_file(siteName, url):
    filename = os.path.basename(url)
    if not os.path.isfile(siteName + '/' + filename):
        print('[+] image\t: ' + url)
        urllib.urlretrieve(url, siteName + '/' + filename)
        
def get_file(url):
    res = urllib2.urlopen(url)
    html = res.read()
    return html

def make_dir(d):
    if not os.path.exists(d):
        os.makedirs(d)

def show_usage():
    global ver
    print('\tusage : python ' + os.path.basename(sys.argv[0]) + ' [site] [start page] [end page]\n')
    print('\tex    : python ' + os.path.basename(sys.argv[0]) + ' example1.tumblr.com 1 50')
    print('\tex    : python ' + os.path.basename(sys.argv[0]) + ' example2.tumblr.com\n\n')
    
    raise SystemExit
    
def create_index_html(siteName):
    dirs = os.listdir(siteName)
    
    fObj = open(siteName + '.html', "w")
    
    for img in dirs:
        fObj.write('<img src=' + siteName + '/' + img + ' /><br /><br />')
    fObj.close()
    print('[+] result\t: ' + siteName + '.html')
        
if __name__=='__main__':
    print('\nDownload images from tumblr - ver ' + ver + '\n')
    
    
    if(len(sys.argv)==2):
        siteName = sys.argv[1].lower()
    elif(len(sys.argv)==3):
        siteName = sys.argv[1]
        pageStart = int(sys.argv[2])
    elif(len(sys.argv)==4):
        siteName = sys.argv[1]
        pageStart = int(sys.argv[2])
        pageEnd = int(sys.argv[3])
    else:
        show_usage()
    
    pageNum = pageStart
    siteName = re.sub(r'\.tumblr\.com','', siteName)
    siteName = re.sub(r'http://','', siteName)
    siteName = re.sub(r'/','', siteName)
    
    html_url = 'http://' + siteName + '.tumblr.com'
    print('[+] site\t: ' + html_url)
    try:
        for page in range(pageStart, pageEnd+1):
            make_dir(siteName)
            get_link(siteName)
    except:
        print('\n')
http://pastebin.com/MTxuj71s

cara pakeknya:
misalnya mau download semua gambar dari
http://fuckyeahfunnythings.tumblr.com/
ane kepingin download gambar dari page 1-50
Code:
python tumblr.py fuckyeahfunnythings 1 50
atau
Code:
python tumblr.py fuckyeahfunnythings.tumblr.com 1 50
atau
Code:
python tumblr.py http://fuckyeahfunnythings.tumblr.com 1 50
ketiganya bisa tergantung selera ketawa

misalnya ane lagi ngedownload baru sampe halaman 32, truz ane ctrl+c
tinggal dilanjut aja dari halaman 32
Code:
python tumblr.py fuckyeahfunnythings 32 50

ato cukup gini aja
Code:
python tumblr.py fuckyeahfunnythings
dia bakalan mulai ngedownload dari page 1 sampe abis

nanti semua gambar disimpan didalam folder sesuai dengan subdomain dari tumblr-nya, misalkan kasus diatas berarti gambarnya ada di folder fuckyeahfunnythings

screenshot
[Image: es4xma.jpg]

[Image: 9u7zm1.jpg]
Find all posts by this user
Quote this message in a reply
 Reputed by :  ditatompel(+1) , x.intruders(+1) , DC_Julianz(+1) , eidelweiss(+1) , ev1lut10n(+1) , nanda(+1) , rusuh(+1) , Bunga.Mataharry(+1) , Killu4(+1)
01-13-2012, 05:43 PM
Post: #2
KotoM Offline
Covergay Dewa
Posts: 558
Joined: May 2011
Reputation: 58
RE: Script untuk download semua gambar dari tumblr
ngakak om ketek koleksi foto bokep hah
Find all posts by this user
Quote this message in a reply
01-13-2012, 05:45 PM (This post was last modified: 01-13-2012 05:46 PM by ditatompel.)
Post: #3
ditatompel Offline
Administrator
*******
Administrators
Posts: 2,168
Joined: Dec 2010
Reputation: 367
RE: Script untuk download semua gambar dari tumblr
Wkwkwkwkwkwkwk... Mantappppppp mantap
Btw, ini pake python 2.x ya om?
Ane ijin sesuain ama versi di kompi ane om ketek... smangat
Find all posts by this user
Quote this message in a reply
01-13-2012, 05:45 PM (This post was last modified: 01-13-2012 05:46 PM by ketek.)
Post: #4
ketek Offline
bocah ingusan
*******
Administrators
Posts: 2,168
Joined: Jan 2010
Reputation: 369
RE: Script untuk download semua gambar dari tumblr
wakkakwakwakwkkwakawk nohope


anu omz... sebenernya koleksi gambar gambar lucu mimisan


@om dita: iya omz.. ane pake versi 2.x .. silahkeun.. diposting ya hasil modifannya smangat
Find all posts by this user
Quote this message in a reply
01-13-2012, 05:46 PM
Post: #5
g4t4n4 Offline
./Devilz Officer
Posts: 145
Joined: Dec 2011
Reputation: 4
RE: Script untuk download semua gambar dari tumblr
mantep oM ngakak
Visit this user's website Find all posts by this user
Quote this message in a reply
01-13-2012, 06:11 PM (This post was last modified: 01-13-2012 06:13 PM by jackerp.)
Post: #6
jackerp Offline
./Devilz Advisor
Posts: 576
Joined: Jan 2011
Reputation: 41
RE: Script untuk download semua gambar dari tumblr
mantap
banget Om..............
Zin Coba Dulu Om...........
Visit this user's website Find all posts by this user
Quote this message in a reply
01-13-2012, 06:16 PM
Post: #7
ketek Offline
bocah ingusan
*******
Administrators
Posts: 2,168
Joined: Jan 2010
Reputation: 369
RE: Script untuk download semua gambar dari tumblr
baru sekali jalan coding doang omz,, masih banyak error/inkonsisten
ketawa

ntar klo ada waktu ane sempurnakan mantap
Find all posts by this user
Quote this message in a reply
01-13-2012, 06:17 PM
Post: #8
CitooZz Offline
./pemburu kimblak
**
Moderators
Posts: 1,296
Joined: Jun 2011
Reputation: 22
RE: Script untuk download semua gambar dari tumblr
mimisan ane coba dulu om ketek ketawa
Find all posts by this user
Quote this message in a reply
01-13-2012, 06:38 PM
Post: #9
Patronum_inc Offline
./Devilz Commander
Posts: 364
Joined: Dec 2011
Reputation: 53
RE: Script untuk download semua gambar dari tumblr
nice share omz ketek wkwkwk ..
mantap mantap
Find all posts by this user
Quote this message in a reply
01-13-2012, 06:58 PM
Post: #10
Killu4 Away
./Devilz Advisor
Posts: 744
Joined: Nov 2011
Reputation: 16
RE: Script untuk download semua gambar dari tumblr
Maaf om ketek,ane mau tanya gmn caranya jalanin script phyton di windows om ?
Maaf kalau pertanyaan ane bodoh,ane bnr2 ga ngerti soalnya malu
Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Pages (3): 1 2 3 Next »
Post Reply 


Topic Tools
Topic Link :
BBCode :
HTML Code :
View a Printable Version Send Thread to a Friend Subscribe to this thread
Submit Google Submit Face book Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Tutor] Slideshare Disabled Python Looping Slide Download hitheir 9 204 01-27-2013 05:53 PM
Last Post: sotbot
  programming python untuk web alessandra 11 1,303 11-12-2012 08:24 PM
Last Post: qpdll
  [uler kadut]script sederhana membuat proses timeout ce.dealova 22 4,242 08-04-2012 08:16 PM
Last Post: perlman
  Script sederhana buat upload source file ke pastebin ditatompel 14 1,594 02-06-2012 03:43 PM
Last Post: ditatompel
  [Tutor] VKDownloader Python Script p0pc0rn 8 860 01-27-2012 05:49 PM
Last Post: ketek
  E-book python lengkap untuk belajar dasar python,.... badwolves1986 11 4,311 06-11-2011 10:41 PM
Last Post: easy2study
  kill script masokis 4 937 05-15-2011 03:34 PM
Last Post: flame_1221

Users Browsing
1 Guest(s)

  • Contact Us
  • devilzc0de
  • Return to Top
  • Mobile Version
  • RSS Syndication
  • Help
Current time: 05-22-2013, 03:30 AM Powered By MyBB, © 2002-2013 MyBB Group. Theme created by Justin S. | Mixed By Chaer.Newbie | Fixed By Aditya

USING THIS SITE INDICATES THAT YOU HAVE READ AND ACCEPT OUR TERMS. IF YOU DO NOT ACCEPT THESE TERMS, YOU ARE NOT AUTHORIZED TO USE THIS SITE