Example code for read web site
Code://////////////////////////////////////////////////////////////////////////////////
// Download CBOE page source code in a text variable
// And returns the result
//////////////////////////////////////////////////////////////////////////////////
string ReadCBOE()
{
string cookie=NULL,
headers;
char post[],
result[];
string TXT="";
int res;
//--- to work with the server, you must add the URL "https://www.google.com/finance"
//--- the list of allowed URL (Main menu-> Tools-> Settings tab "Advisors"):
string google_url="http://ec.forexprostools.com/?columns=exc_currency,exc_importance&importance=1,2,3&calType=week&timeZone=15&lang=1";
//---
ResetLastError();
//--- download html-pages
int timeout=5000; //--- timeout less than 1,000 (1 sec.) is insufficient at a low speed of the Internet
res=WebRequest("GET",google_url,cookie,NULL,timeout,post,0,result,headers);
//--- error checking
if(res==-1)
{
Comment("WebRequest error, description =",ErrorDescription(GetLastError()));
MessageBox("You must add the address ' "+google_url+"' in the list of allowed URL tab 'Advisors' "," Error ",MB_ICONINFORMATION);
//--- You must add the address ' "+ google url"' in the list of allowed URL tab 'Advisors' "," Error "
}
else
{
//--- successful download
//PrintFormat("File successfully downloaded, the file size in bytes =%d.",ArraySize(result));
//--- save the data in the file
int filehandle=FileOpen("news-log.html",FILE_WRITE|FILE_BIN);
//--- ïðîâåðêà îøèáêè
if(filehandle!=INVALID_HANDLE)
{
//---save the contents of the array result [] in file
FileWriteArray(filehandle,result,0,ArraySize(result));
//--- close file
FileClose(filehandle);
int filehandle2=FileOpen("news-log.html",FILE_READ|FILE_BIN);
TXT=FileReadString(filehandle2,ArraySize(result));
FileClose(filehandle2);
}
else
{
Comment("Error in FileOpen. Error description =",ErrorDescription(GetLastError()));
}
}
return(TXT);
}