PredictionFromWebParsingExample

Author: Copyright 2018, MetaQuotes Software Corp.
0 Views
0 Downloads
0 Favorites
PredictionFromWebParsingExample
ÿþ//+------------------------------------------------------------------+

//|                              PredictionFromWebParsingExample.mq5 |

//|                        Copyright 2018, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2018, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"



string comm = "";

//+------------------------------------------------------------------+

//| Script program start function                                    |

//+------------------------------------------------------------------+

void OnStart()

  {

   comm = "";

   Open_positions_takeprofit();

   Comment(comm);

  }

//+------------------------------------------------------------------+

void Open_positions_takeprofit()     

  {

   string urlTakeprofit = "https://take-profit.org/banksfull.php";

   char post[];

   char result[];

   string headers; // MB8 ?5@5<5==K5 =C6=K 4;O >B?@02:8 70?@>A0 =0 A09B

   

   int webRequest = WebRequest("GET", urlTakeprofit, NULL, NULL, 1000, post, 0, result, headers); // B?@02;O5< http 70?@>A =0 A09B

   if(webRequest==200) { // 5A;8 CA?5H=>, B> @01>B05< 40;LH5, 8=0G5 ?8H5< >1 >H81:5.

      string textResult = CharArrayToString(result, 0, WHOLE_ARRAY, CP_UTF8); // >;CG5==K9 >B A5@25@0 <0AA82 A8<2>;>2 (char) ?5@52>48< 2 B5:AB.

      int textStart = StringFind(textResult, "B:@KBK5 ?>78F88"); // 40;55 =0G8=05BAO ?0@A8=3

      int textFinish = StringFind(textResult, "</table>", textStart);

      string textNeeded = StringSubstr(textResult, textStart, textFinish-textStart); // 0;55 =0E>48< =C6=K9 =0< CG0AB>: B5:AB0 A =C6=K<8 =0< 40==K<8

      

      string t;

      int s = StringFind(textNeeded, "<tr", 0);

      int e = StringFind(textNeeded, "</tr>", s);

      while((s = StringFind(textNeeded, "<tr", e)) != -1) { // !>18@05< 2A5 AB@>:8 87 B01;8FK

         e = StringFind(textNeeded, "</tr>", s);

         t = StringSubstr(textNeeded, s, e-s);

         Parse_Open_positions_takeprofit(t); //  0A?>7=05< (?0@A8<) 7=0G5=8O 87 AB>;1F>2 :064>9 AB@>:8 A ?><>ILN 2A?><>30B5;L=>9 DC=:F88

      }

      

   } else Print("WebRequest error: "+IntegerToString(webRequest));

  }

void Parse_Open_positions_takeprofit(string str)

  {

   int s, e;

   s = StringFind(str, "<td>", 0);

   e = StringFind(str, "</td>", s);

   string t1 = StringSubstr(str, s+4, e-(s+4)); // ?5@2K9 AB>;15F - 20;NB=0O ?0@0, 8 B.4.

   s = StringFind(str, "<td>", e);

   e = StringFind(str, "</td>", s);

   string t2 = StringSubstr(str, s+4, e-(s+4));

   s = StringFind(str, "</i>", e);

   e = StringFind(str, "</span>", s);

   string t3 = StringSubstr(str, s+4, e-(s+4));

   s = StringFind(str, "<td>", e);

   e = StringFind(str, "</td>", s);

   string t4 = StringSubstr(str, s+4, e-(s+4));

   s = StringFind(str, "<td>", e);

   e = StringFind(str, "</td>", s);

   string t5 = StringSubstr(str, s+4, e-(s+4));

   s = StringFind(str, "<td>", e);

   e = StringFind(str, "</td>", s);

   string t6 = StringSubstr(str, s+4, e-(s+4));

   s = StringFind(str, "<td>", e);

   e = StringFind(str, "</td>", s);

   string t7 = StringSubstr(str, s+4, e-(s+4));

   

   string row = t1 + "\t" + t2 + "\t" + t3 + "\t" + t4 + "\t" + t5 + "\t" + t6 + "\t" + t7 + "\n";

   comm = comm + row;

}

//=========================================================================================================================================

Comments