csv - Downloading Many Files using Python Web-Scraping -


if have link csv on yahoo finance: http://ichart.finance.yahoo.com/table.csv?s=low&d=4&e=29&f=2014&g=d&a=8&b=22&c=1981&ignore=.csv

how write web scraper download multiple files based on list of symbols: [low, spy, aapl]

from stringio import stringio  urllib2 import urlopen  symbol in symbols:     f = urlopen ('http://www.myurl.com'+symbol+'therestoftheurl')     p = f.read()     d = stringio(p)     f.close 

do need write contents of url file, or download automatically directory?

you can use method download files:

import urllib2  file_name = "myfile.xyz" u = urllib2.urlopen(url) f = open(file_name, 'wb')  block_sz = 4096 while true:     buffer = u.read(block_sz)     if not buffer:         break     f.write(buffer)  f.close() 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -