Skip to content

Instantly share code, notes, and snippets.

@gunyarakun
Created December 28, 2009 11:43
Show Gist options
  • Save gunyarakun/264640 to your computer and use it in GitHub Desktop.
Save gunyarakun/264640 to your computer and use it in GitHub Desktop.
#インターネットショートカットファイル(*.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