[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Script for downloading from different servers



PureBytes Links

Trading Reference Links

Thank you very much, Michael. I'm confident it will solve this really annoying problem.

Thanks again,

Franco

--- In amibroker@xxxxxxxxxxxxxxx, "Michael.S.G." <OzFalcon@xxxx> wrote:
>
> fgornati,
> 
> You can retrieve web pages directly from the script (JScript). You don't 
> need to use urlget program.
> 
> Here is a script that retieves data from a different location, But Im 
> sure you can modify it to suite your needs.
> Just copy & past the following to a textfile and rename as 
> "whatever.js". Be sure to have the .js extension.
> You must also have windows scripting host installed (But I presume you 
> already have this installed).
> 
> /*
> ** AmiBroker/Win32 script.
> **
> ** File:    ASCII-MktData-Get.js
> ** Updated:    October, 11th, 2005
> ** Purpose:    Download MarketData from ASCII-Data.com
> ** Language:    JavaScript (Windows Scripting Host)
> ** Author:    Michael.S.G aka OzFalconAB@xxxx
> */ Version =    "1.04";
>  
> /* Main Script Body Start */
> WScript.Echo( "ASCII-MktData-Get V" + Version + " Started" );
> try
> {
> /* Common Global Variables /*
> /* Input URL Location */
> url = "http://www.ascii-data.com/stocktable1.csv";;
> /* Data Storage Dir */
> StoreDIR = "StoreRAW/";
> /* Output Data filename */
> OutFile1 = "stocktable";
> OutFile2 = ".csv";
> OutFile = StoreDIR+OutFile1+OutFile2;
> ArcFile = StoreDIR+OutFile1+"_"+BuildDate()+OutFile2;
> 
> /* Core Global Variables */
> var xmlHttpObj, Temp;
> var fso, fwrite, fread, rline;
> var ForReading = 1;
> var ForWriting = 2;
> var ForAppending = 8;
> var HTMLData;
> 
> /* Create file system object */
> fso = new ActiveXObject( "Scripting.FileSystemObject" );
> 
> /* Create xmlHTTP Object */
> xmlHttpObj = new ActiveXObject("microsoft.xmlhttp");
> 
> /* Create Folder if needed */
> if(!fso.FolderExists(StoreDIR)) Temp = fso.CreateFolder(StoreDIR);
> 
> /* Core Script Function Start */
> 
> HTMLData = getHTML(url);
> SaveFile(HTMLData,OutFile); // Save copy for Processing
> SaveFile(HTMLData,ArcFile); // Save copy for Archiving
> 
> /* Core Script Function End */
> }
> catch (e) { WScript.echo( "An Error has occured and operation can not be 
> completed."); }
> finally
>  { WScript.Echo( "ASCII-MktData-Get Ending." ); }
> /* Main Script Body End */
> 
> /* Declared Functions */
> function BuildDate()
> {
>     /* Local Variables */
>     var d,fyear,fmonth,fday;
>     var s = "";
> 
>     d = new Date();
>     fyear = d.getYear() ;
>     fmonth = (d.getMonth() + 1) ;
>     fday = d.getDate() ;
>     if (fday < 10) fday = "0" + fday;
>     if (fmonth < 10) fmonth = "0" + fmonth;
>     s = fyear+""+fmonth+""+fday; //Force s to be a string.
>     return s;
> }
> 
> function getHTML(urlGET)
> {
>     /* Local Variables */    
>     var html = "NoData";
>     var status, statustxt;
> 
>     try
>     {
>     xmlHttpObj.open("GET",urlGET,false);
>     xmlHttpObj.send();
>     status = parseInt(xmlHttpObj.status);
>     statustxt = String(xmlHttpObj.statustext);
>     if (status == 200) {html = String(xmlHttpObj.responsetext);}
>     else
>     { WScript.Echo ("Problem retrieving:\n" + urlGET + "\nSystem 
> reports: " + statustxt);
>     throw e; }
>     }
>     catch (e)
>     {
>     WScript.Echo( "System Failed to Access URL" );
>     throw e; // exit, connection attempt failed.
>     } 
>     return html;
> }
> 
> function SaveFile(FileData,FileOUT)
> {
> try {fwrite = fso.OpenTextFile( FileOUT, ForWriting, true);}
> catch(e) {WScript.echo( "There is a problem opening " + FileOUT + " For 
> Writing."); throw e;}
> 
> try {fwrite.Write( FileData );}
> catch(e) {WScript.echo( "There is a problem Writing " + FileOUT ); throw e;}
> finally {fwrite.close();}
> }
>





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/