read a web site contents

 

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:

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

 
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
 
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.

 
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
 
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


 
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?

 
i used your code Lorentzos Roussos but i get nothing on the alert.
 
   string cookie=NULL,headers;
   char post[],result[];
   int res;
   int timeout=5000;
//--- to enable access to the server, you should add URL 
//--- in the list of allowed URLs (Main Menu->Tools->Options, tab "Expert Advisors"):
   string url="https://";//check if its http or https
//--- Reset the last error code
   ResetLastError();
//--- Loading a html page from Google Finance
   res=WebRequest("GET",url,cookie,NULL,timeout,post,0,result,headers);
//--- Checking errors
   if(res==-1)
     {
      Print("Error in WebRequest. Error code  =",GetLastError());
      //--- Perhaps the URL is not listed, display a message about the necessity to add the address
      MessageBox("Add the address '"+url+"' in the list of allowed URLs on tab 'Expert Advisors'","Error",MB_ICONINFORMATION);
     }
   else
     {
      //--- Load successfully
      PrintFormat("The file has been successfully loaded, File size =%d bytes.",ArraySize(result));
      //create string with the result
      int tit=ArraySize(result)-1;
      string html="";
      for(int xx=0;xx<=tit;xx++)
       {
       html=html+CharToStr(result[xx]);
       }
     Alert(html);
     //BNC_API_RESPONSE=html;
     }    

Here is an update