Downloading multiple csv files from a website

tkpmep at hotmail.com tkpmep at hotmail.com
Fri Aug 17 15:35:28 EDT 2007


Mike,

Thanks for the pointers. I looked through the ASPN cookbook, but found
a more reliable (and easier to implement) way to get the files I want.
I downloaded GNU Wget from http://users.ugent.be/~bpuype/wget/( the
current version is 1.10.2), and then ran it from Python as follows

import os
rc = os.system('wget --debug --output-document="c:\\downloads\
\russell1000index_cyr.csv" --output-file=log.txt
http://www.russell.com/common/indexes/csvs/russell1000index_cyr.csv')


rc is the return code, and is 0 if the download succeeds. I also tried
the subprocess module

import subprocess
f = subprocess.Popen('wget --debug --output-document="c:\\downloads\
\russell1000index_cyr.csv" --output-file=log.txt
http://www.russell.com/common/indexes/csvs/russell1000index_cyr.csv')

This, too, works just fine. Wget does a lot more error-checking than
the recipe in the Python cookbook, does FTP as well as http, and
supports OpenSSL - its essentially a one-stop solution. In addition, I
can write batch files that do all the downloads without any need for
Python to be installed on the machine.

Thanks again

Thomas Philips




More information about the Python-list mailing list