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

 

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.
 
Show your attempt if you need coding help. "Doesn't work" is not very helpful.
 
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).
 
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..
 
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.
 
Alain Verleyen:
lol...you like simplicity.
At least it works.
 
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
 
aura:
At least it works.
I never get any problem with WebRequest. I suppose you are not using Windows ?
 
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.
 
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.
 
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.