'2009/09/22'에 해당되는 글 1건

  1. 2009.09.22 티스토리 음원 다운로드 프로그램 (python) 2
자료2009. 9. 22. 12:52



import urllib
import re
import os

url=raw_input("Enter tistory url : ")
page=urllib.urlopen(url)
content=page.read()
title=re.search("<title>.+:: (.+)</title>",content).group(1).decode("utf-8").encode("euc-kr")
print "page title :",title,"\n"
cwd=os.getcwd()
target=set(re.findall("(http://(cfs\d+\.tistory\.com/u|cfile\d+\.uf\.tistory\.com/o)[\w%\.:/\?=]+)\">(.+?)</a>",content))
page.close()
title=title.replace(":","-")
if(os.access(title,os.F_OK)==False):
 os.mkdir(title)
os.chdir(title)
for item in target:
 url=item[0]
 name=item[2]
 if(name[-4:]!=".mp3"):
  name=name+".mp3"
 print "Downloading", name
 music=urllib.urlopen(url)
 fp=open(name,"wb")
 fp.write(music.read())
 fp.close()
 music.close()



티스토리 블로그 주소를 입력하면 해당 포스트에 포함된 음원을 다운받아주는 파이선 프로그램.

테스트를 많이 해보진 않아서 모든 경우에 되는지는 잘 모르겠다;

Posted by jongwook