>> Delete No. 971 article
No. 파이썬으로 라이코스 만화 긁어보기.

등록 2001-01-30 15:19:00     조회 5
이름 박응용    

		라이코스 만화 좋아 하시나요?
밑에 라이코스 만화 긁어오는 스크립트가
몇개 있던데 좀 불편하더군요...
제가 만든 파이썬 버젼은 만화책 이름만 알고 있으면 됩니다.
소스중에 COMICDIR 부분만 고치고 사용하시면 됩니다.
COMICDIR 은 만화가 저장될 디렉토리 입니다.
  #!/usr/bin/env python
 import os
import string
import glob
import sys
import urllib
import re
  # global
COMICDIR = '/home/pey/comic/'  # 요기를 자신에 맞게 고쳐주세요.
  def fetch(title, dir, code, booknum):
    if code: url_base = "http://comics.lycos.co.kr/단행본/%s/" % title
    else: url_base = "http://comics.lycos.co.kr/블랙탄/%s/" % title
    for i in booknum:
        condition = 0
        i = string.strip(i)
        for j in range(200):    #XXX over 200 ??
            page = j+1
            if code:
                url_complete = url_base + string.zfill(i,2) +
                    '/' + code+string.zfill(i,2)+ '-' +
                    string.zfill(str(page),3) + ".jpg"
            else:
                url_complete = url_base + string.zfill(i,2) +
                    '/' + string.zfill(str(page),3) + ".jpg"
            save_jpg=dir+'/'+string.zfill(i,2)+
                string.zfill(str(page),3)+".jpg"
            wget_out = os.system("wget -T 10 -O %s %s"
                % (save_jpg, url_complete))
            if not wget_out: condition = 1
            if not condition and i == string.strip(booknum[0]):
                print "입력이 잘못 되었습니다."
                os.system("rm -rf %s" % dir)
                sys.exit(2)
  def delzerofile(target_dir):
    os.chdir(target_dir)
    jpglist = glob.glob('*')
    for i in jpglist:
        if os.path.getsize(i) == 0:
            os.unlink(i)
 if __name__ == '__main__':
    title = string.strip(raw_input("만화이름: "))
    tmp = string.strip(raw_input( "만화책번호를  입력하세요."+
        " ',' 로 구분.1,2,3 권을 받을때: ex) 1,2,3 >> "))
    num = string.split(tmp, ',')
    url = "http://comics.lycos.co.kr/comicview1.asp?title=%s&volume=1&page=1"
        % title
    m = re.compile(r'.*01/(.*)01-00',re.DOTALL)
    p = m.match(urllib.urlopen(url).read())
    target_dir = COMICDIR+title
    os.system("mkdir %s" % target_dir)
    if p: code = p.group(1); fetch(title, target_dir, code, num)
    else: fetch(title, target_dir,None,num)
    delzerofile(target_dir)
[관리자] 패스워드를 입력 하십시오. 답장이 존재하면 함께 삭제됩니다.[ 목록 | 이전 ]
패스워드:    

Copyleft 1999-2026 by JSBoard Open Project
Theme Designed by IDOO All right reserved