1

First off, sorry for the lack of code; verbiage is the only thing that I can think of using to describe the problem

I have a link which when I run it using:

webbrowser.open('http://www.MyLink&ticker=IBM') 

automatically downloads IBM data for me. The file is automatically named download.csv

The next time I run this it tries to use the same name and therefore I get a file download(1).csv and so on.

There are 2 things I wish to accomplish.

  1. Open the file download.csv and rename it ticker_Date.csv where ticker would be IBM or GE, etc and date is the previous biz day. This way I avoid file names download(1) download(2) etc and can actually have the file name associated with the ticker (IBM for example) and the trade date the data is from

  2. Not open 20 web browser pages if I request 20 different tickers by closing the webbrowser after the download is complete.

I tried:

with urllib.request.urlopen(url) as response, open(file_name, 'wb') as out_file:
shutil.copyfileobj(response, out_file)

I don't seem to be able to get this to work. To be clear, when I enter the url a download automatically takes place. All of the resources I have seen have referenced "downloading" a file with a "file_Name", but this is automatically done in my case. I don't have a file name per-say

thanks for any help

John
  • 531
  • 1
  • 8
  • 23
  • Send a HTTP request to download the file, without using a web browser – BeniBela Jul 25 '15 at 14:43
  • Thanks for the point in the right direction BeniBela, I tried to figure this out . . .with no success :-( – John Jul 25 '15 at 16:15
  • Try [this](http://stackoverflow.com/questions/19602931/basic-http-file-downloading-and-saving-to-disk-in-python)? – BeniBela Jul 25 '15 at 21:17
  • Thanks again Bela, I actually tried each of those suggestions (in Link) after your first comment. All that happens is a filename shows up with zero Bytes in it. I am not sure if it is because no filename is selected, but rather a download is "triggered" rather than specifically requested. – John Jul 26 '15 at 15:13
  • I do not understand what you mean by "triggered" – BeniBela Jul 26 '15 at 16:58
  • when i enter the URL into Mozilla or Chrome and hit enter, the file for the symbol in the URL (in my example i used IBM) automatically starts downloading rather than me entering the name of a file I am interested in downloading. Each time I do this a file with the name data.csv is downloaded to my pc – John Jul 26 '15 at 21:01

0 Answers0