HTTPrequest query for a CSV file download

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
andywilliams
Newbie
Posts: 4
Joined: Sat Apr 21, 2007 10:00 am

HTTPrequest query for a CSV file download

Post by andywilliams » Sat Apr 21, 2007 10:11 am

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,

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Apr 21, 2007 11:19 am

For some reason I'm getting a 404 error when using HTTPRequest. However, the following works:

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
Just change your desired output filename at the top.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

andywilliams
Newbie
Posts: 4
Joined: Sat Apr 21, 2007 10:00 am

Thank you

Post by andywilliams » Sat Apr 21, 2007 7:03 pm

Thank you - the code you suggested works a treat!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts