Hi - experienced programmer but this is my first Python program. This URL will retrieve an excel spreadsheet containing (that day's) msci stock index returns.
http://www.mscibarra.com/webapp/indexperf/excel?priceLevel=0&scope=0¤cy=15&style=C&size=36&market=1897&asOf=Jul+25%2C+2008&export=Excel_IEIPerfRegional Want to write python to download and save the file. So far I've arrived at this: [quote] # import pdb import urllib2 from win32com.client import Dispatch xlApp = Dispatch("Excel.Application") # test 1 # xlApp.Workbooks.Add() # xlApp.ActiveSheet.Cells(1,1).Value = 'A' # xlApp.ActiveWorkbook.ActiveSheet.Cells(2,1).Value = 'B' # xlBook = xlApp.ActiveWorkbook # xlBook.SaveAs(Filename='C:\\test.xls') # pdb.set_trace() response = urllib2.urlopen('http://www.mscibarra.com/webapp/indexperf/ excel? priceLevel=0&scope=0¤cy=15&style=C&size=36&market=1897&asOf=Jul +25%2C+2008&export=Excel_IEIPerfRegional') # test 2 - returns check = False check_for_data = urllib2.Request('http://www.mscibarra.com/webapp/ indexperf/excel? priceLevel=0&scope=0¤cy=15&style=C&size=36&market=1897&asOf=Jul +25%2C+2008&export=Excel_IEIPerfRegional').has_data() xlApp = response.fp print(response.fp.name) print(xlApp.name) xlApp.write xlApp.Close [/quote] -- http://mail.python.org/mailman/listinfo/python-list