Download MetaTrader 5

read a web site contents

To add comments, please log in or register
Publish your application in Cobe Base. Millions of traders will see it!
Mahmoud Farajpour
233
Mahmoud Farajpour 2016.01.12 10:40 

i have a website contains trading signals how do i let my ea read my website contents?

i have used function WebResquest to do that but all i receive is numbers

Take a look at the example provided at http://docs.mql4.com/common/webrequest

i have added Alert(result[0]);   to see what server respond back,

 Alert(result[1]);

Alert(result[2]);

.

.

.

The array result allways contains numbers now i want to know how to recive contents at the website I send webrequest to,For example if i send a Webrequest to yahoo.com i want to have yahoo.com contents in function response It could be even html codes

WebRequest - MQL4 Documentation
  • docs.mql4.com
WebRequest - MQL4 Documentation
Alain Verleyen
Moderator
30739
Alain Verleyen 2016.01.12 12:37  
Mahmoud Farajpour
233
Mahmoud Farajpour 2016.01.12 13:01  
Alain Verleyen:

I thought they made this forum to discuss problems, is that u say to all?

Lorentzos Roussos
9335
Lorentzos Roussos 2016.01.12 13:24  
Hello . The result array contains bytes . Use function CharToString to convert data .

This is what i do :

   string cookie=NULL,headers;
   char post[],result[];
   int res;
   string target_url="http://";
   ResetLastError();
   int timeout=5000; 
   res=WebRequest("GET",target_url,cookie,NULL,timeout,post,0,result,headers);

      //create string with the result
      int tit=ArraySize(result)-1;
      string html="";
      for(int xx=0;xx<=tit;xx++)
       {
       html=html+CharToStr(result[xx]);
       }

   //Find broadcast start 
   int broad_start=StringFind(html,"{!}",0);
   int broad_end=StringFind(html,"{!}",broad_start+3);
   //find length
   int broad_len=(broad_end-1)-(broad_start+3);
   string extract=StringSubstr(html,broad_start+3,broad_len);
   Alert(extract);
I include content intended for MT4 Between this set of characters {!} and this is what the extract prints
Alain Verleyen
Moderator
30739
Alain Verleyen 2016.01.12 13:39  
mahmood0:

I thought they made this forum to discuss problems, is that u say to all?

I suggest you to calm down. There is nothing wrong in my post.

Mahmoud Farajpour
233
Mahmoud Farajpour 2016.01.12 14:24  
Lorentzos Roussos:
Hello . The result array contains bytes . Use function CharToString to convert data .

This is what i do :

I include content intended for MT4 Between this set of characters {!} and this is what the extract prints
Thank you so much im going to test your code i hope it work
Mahmoud Farajpour
233
Mahmoud Farajpour 2016.01.12 14:50  
Lorentzos Roussos:
Hello . The result array contains bytes . Use function CharToString to convert data .

This is what i do :

I include content intended for MT4 Between this set of characters {!} and this is what the extract prints

Thanks Lorentzos you were right, I placed a url in your code and i got all the html code of that url


Mahmoud Farajpour
233
Mahmoud Farajpour 2016.01.12 15:24  
Lorentzos Roussos:
Hello . The result array contains bytes . Use function CharToString to convert data .

This is what i do :

I include content intended for MT4 Between this set of characters {!} and this is what the extract prints

Why sometimes the html code returned by your code is alittle different than the html i view by my web browser?

is that because of {!}  ?I mean is that a separator  between html codes?And why not to use CharArrayToString instead of that?

To add comments, please log in or register