Internet Read function does not read updates

 

Hello,

i have a function created with wininet which does read the website content into a string and i am wondering, when i change the website content then the function does not show me the new content, but when i close metatarder and start new, then he show me now the new website content, but why must i first close and restart the metatrader? Can the function not give me direct the new website content without restarting MT4?


//+------------------------------------------------------------------+
//|                                                    Indicator.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window

//+------------------------------------------------------------------+
//| Imported functions description                                   |
//+------------------------------------------------------------------+
#import "wininet.dll"
int InternetOpenW(
                  string     sAgent,
                  int        lAccessType,
                  string     sProxyName="",
                  string     sProxyBypass="",
                  int     lFlags=0
                  );
int InternetOpenUrlW(
                     int     hInternetSession,
                     string     sUrl,
                     string     sHeaders="",
                     int     lHeadersLength=0,
                     int     lFlags=0,
                     int     lContext=0
                     );
int InternetReadFile(
                     int     hFile,
                     uchar     &sBuffer[],
                     int     lNumBytesToRead,
                     int     &lNumberOfBytesRead
                     );
int InternetCloseHandle(
                        int     hInet
                        );
#import

int hSession_IEType;
int hSession_Direct;
int Internet_Open_Type_Preconfig=0;
int Internet_Open_Type_Direct=1;


input string URL="http://www.websiteurl.net/file.php";



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
//----
   return(0);
//----
  }




//+--------------------------------------------------------------------+
//|                                                                    |
//+--------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
//----
  }



//+--------------------------------------------------------------------+
//|                                                                    |
//+--------------------------------------------------------------------+
int start()
  {
//----
  
   string str=httpGET(URL);
   Print("website ",str);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int hSession(bool Direct)
{
//---
  string InternetAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)";
  if(Direct)
    {
      if(hSession_Direct==0)
        {
         hSession_Direct=InternetOpenW(InternetAgent,Internet_Open_Type_Direct,"0","0",0);
        }

    return(hSession_Direct);
    }
  else
   {
      if(hSession_IEType==0)
        {
         hSession_IEType=InternetOpenW(InternetAgent,Internet_Open_Type_Preconfig,"0","0",0);
        }

    return(hSession_IEType);
   }
//---
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string httpGET(string strUrl)
{
//---
   int handler=hSession(false);
   int response= InternetOpenUrlW(handler,strUrl);
   if(response == 0)return(false);

   uchar ch[100]; string toStr=""; int dwBytes,h=-1;
   while(InternetReadFile(response,ch,100,dwBytes))
     {
      if(dwBytes<=0) break; toStr=toStr+CharArrayToString(ch,0,dwBytes);
     }

   InternetCloseHandle(response);
   return(toStr);
//---
}




 
try to close the hSession
 
PlanandTrade:

Hello,

i have a function created with wininet which does read the website content into a string and i am wondering, when i change the website content then the function does not show me the new content, but when i close metatarder and start new, then he show me now the new website content, but why must i first close and restart the metatrader? Can the function not give me direct the new website content without restarting MT4?


Try forcing the InternetOpenUrl() to reload the content from the server (rather than from the cache) by setting the INTERNET_FLAG_RELOAD.
 
thank you, it have work with that Tip INTERNET_FLAG_RELOAD.
 

Hello guys,

i just found yor Indicator code. I also want to read a content from a website. I coppied the indicator added my own website and it is running very well! My question now is, how can I set the exact characters or int's I want to read from this website? 

I found something in the Terminal which seems to be from the website I want to read. The red underlined parts belong to the content of the website. But now I want to read sth. diffrent. Maybe you can tell me how.


Thank you

This picture contains two print commands

Files:
bsp.txt  2 kb
Reason: