Discussion Locked

Automate file download through HTTP.

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

A friend has approached me with this problem:

He needs to get the target file from the following URL:

http://ichart.finance.yahoo.com/table.csv?s=UPS&d=5&e=21&f=2005&g=d&a=10&b=10&c=1999&ignore=.csv

and land it on one of his local netowrk shares. He cannot run IIS so ASP is out of the question.

I was thinking of a scheduled task to run IE and pass the URL as a command line argument. The problem with that is you still have to answer the file download dialog.

What's the best ultra low footprint solution for doing this on a 2000 or XP machine?

Thanks.

9 replies

by dryflies

download active perl and write a script to "Get" the url. Then write the result to disk. No IE required. it is less than 50 lines of perl and can be run from the task scheduler. The following is an example from O'reilly's perl in a nutshell.

use LWP::UserAgent;

$hdrs = new HTTP::Headers(Accept => 'text/plain',
User-Agent => 'MegaBrowser/1.0');

$url = new URI::URL('www.ora.com/index.html');
$req = new HTTP::Request(GET, $url, $hdrs);
$ua = new LWP::UserAgent;
$resp = $ua->request($req);
if ($resp->is_success) {
print $resp->content;}
else {
print $resp->message;}
Please remember to rate this answer.

by ebuild

When IE receive a file that he can't parse it, he pass it to OS, this why you get "the file download dialog".
Think about web services.

by saustin

I am attempting to use this solution but when I try to write webObj.responseText to the text or csv file I created, I get an error seemingly due to the fact that webObj.responseText includes non-ASCII characters which will not write. I have also been unable to replace the non-ASCII character. It shows up in the text as ? but cannot be found with a replace search like Replace(webObj.responseText,"?", ""). Any suggestions?

by tkaveh

This seems great - but I have a similar project where I need to first authenticate, then navigate through a series of .do pages, THEN download a .csv . I found some good stuff on MSDN, but what about the navigation parts? Thanks!

by yasimmot

Could you please advise what off-the-shelf tools or code snippets are available to (schedulled) downloading file from https:// site via https.

This discussion is closed to new replies.