Download MetaTrader 5

How do I open an URL and download a file from URL?

To add comments, please log in or register
aura
43
aura  

I need to open an URL and download a file from URL. Standard functions, such as InternetOpenUrlW, and native Windows libraries, are using Internet Explorer, but I need to get access to file without Internet Explorer. Moreover, this particular page does not open through IE (but open in different browsers), but it does not matter.

WebRequest does not work too.
Alain Verleyen
Moderator
32418
Alain Verleyen  
Show your attempt if you need coding help. "Doesn't work" is not very helpful.
aura
43
aura  
string cookie=NULL,headers;
char post[],result[];
string url="http://www.dailyfx.com/files/Calendar-05-14-2017.csv";
int res=WebRequest("GET",url,cookie,NULL,10000,post,0,result,headers);
if(res==-1)
     {
      Print("Error in WebRequest. Error code  =",GetLastError());
     }
   else
     {
     PrintFormat("The file has been successfully loaded, File size =%d bytes.",ArraySize(result));
     }


Error in WebRequest. Error code  =5203


"Doesn't work"
means "it will not work because it uses Internet Explorer too" (the link itself does not open in IE, but open in different browsers).
Carl Schreiber
7092
Carl Schreiber  
I stopped the use of WebRequest and use PowerShell, wget and the TaskScheduler to load and parse such files as I can dld them e.g. Sunday at 20:00 GMT and I don't have to wait for the first tick..
Alain Verleyen
Moderator
32418
Alain Verleyen  
Carl Schreiber:
I stopped the use of WebRequest and use PowerShell, wget and the TaskScheduler to load and parse such files as I can dld them e.g. Sunday at 20:00 GMT and I don't have to wait for the first tick..
lol...you like simplicity.
aura
43
aura  
Alain Verleyen:
lol...you like simplicity.
At least it works.
Carl Schreiber
7092
Carl Schreiber  
Alain Verleyen:
lol...you like simplicity.

It's more than just simplicity!

  1. It works independently from any troubles with mt4/5, broker, connection, ticks..
  2. Some news-server may get into troubles if all around the world try to access the same address at the same tiny moment (the first tick)..
  3. I find parsing with PowerShell is easier than with mql4, e.g. remove html-tags..
  4. With wget I am more flexible and I have more options for the download
Alain Verleyen
Moderator
32418
Alain Verleyen  
aura:
At least it works.
I never get any problem with WebRequest. I suppose you are not using Windows ?
Alain Verleyen
Moderator
32418
Alain Verleyen  
Carl Schreiber:

It's more than just simplicity!

1. It works independently from any troubles with mt4/5, broker, connection, ticks..

Wrong argumentation, you can have problems with any software and you are always depending of some external conditions. There are no special issue to use WebRequest with MT4/MT5.

2. Some news-server may get into troubles if all around the world try to access the same address at the same tiny moment (the first tick)..

How is it related to the discussion ? It's server side.

3. I find parsing with PowerShell is easier than with mql4, e.g. remove html-tags..

Completely subjective. mql4/mql5 has all possibilities to code anything. Certainly html processing.

4. With wget I am more flexible and I have more options for the download

For sure wget is more powerful than WebRequest.  More options, more stability, etc...That's a 20 years old software with a very wide usage, community, etc. But if we talk about HTTP/HTTPS request which are common with WebRequest, what can you do with wget you can't do with WebRequest and mql ?


Just for fun, please don't take this discussion too seriously.
JC
1499
JC  
Alain Verleyen:

There are no special issue to use WebRequest with MT4/MT5.

[...]

what can you do with wget you can't do with WebRequest and mql ? 

One example: you can't use WebRequest in an indicator.
Alain Verleyen
Moderator
32418
Alain Verleyen  
JC:
One example: you can't use WebRequest in an indicator.
Of course I know that, but it's not really what I am asking for.
12
To add comments, please log in or register