I am trying to write a script that will download some financial (share price etc) data from a website daily. The url works fine from Internet Explorer, it downloads a CSV file but I'd like to automate this with a HTTPrequest command.
The url is:
http://www.advfn.com/p.php?pid=filterxd ... str=&zip=0
and the result is a CSV file of about 500K.
I've tried using the HTTPrequest command but it doesn't seem to work.
Any help or ideas appreciated,
HTTPrequest query for a CSV file download
Moderators: JRL, Dorian (MJT support)
-
- Newbie
- Posts: 4
- Joined: Sat Apr 21, 2007 10:00 am
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
For some reason I'm getting a 404 error when using HTTPRequest. However, the following works:
Just change your desired output filename at the top.
Code: Select all
Let>oFile=d:\data.csv
VBSTART
Function HTTPGet(sUrl)
set oHTTP = CreateObject("Microsoft.XMLHTTP")
oHTTP.open "GET", sUrl,false
oHTTP.send
HTTPGet = oHTTP.responseText
End Function
VBEND
Let>URL=http://www.advfn.com/p.php?pid=filterxdownload&show=1_63_,1_64_,1_65_,1_66_,1_67_,1_68_,1_69_,1_70_,1_88_,1_90_,1_27_,1_1_,1_21_,1_51_,1_35_,1_36_&sort=&cnstr=&zip=0
VBEVal>HTTPGet("%URL%"),Result
IfFileExists>oFile
DeleteFile>oFile
Endif
WriteLn>oFile,r,Result
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Newbie
- Posts: 4
- Joined: Sat Apr 21, 2007 10:00 am
Thank you
Thank you - the code you suggested works a treat!