Created
December 28, 2009 11:43
-
-
Save gunyarakun/264640 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#インターネットショートカットファイル(*.url)からファイルを取り出して、これを取得しファイルにセーブする。 | |
import os | |
import glob | |
import urllib2 | |
from urlparse import urlparse | |
import ConfigParser | |
for file in glob.glob('*.url'): | |
try: | |
conf = ConfigParser.RawConfigParser() | |
conf.read(file) | |
url = conf.get('InternetShortcut','URL') | |
savePath = os.path.basename(urlparse(url).path) | |
f = open(savePath, 'wb') | |
con = urllib2.urlopen(url) | |
f.write(con.read()) | |
print 'fetch %s from %s' % (savePath, url) | |
except: | |
print 'error on %s' % [file] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment