Hello. There is a parser for the BC Marathon. He is looking for a certain result in sets (tennis) on live betting. The search takes place after a certain period of time, when a result is found, it signals about it and displays the result in a window, and then this match does not participate in subsequent searches. BUT, as soon as a new match appears or a search is already underway, the search begins anew for all games, again signals games (previously) found, etc. The bottom line is that with a new search (the beginning / end of the match), the results found are shown each in a separate window, and sometimes it is a long process. Tell me how you can display the results of all matches found (in which there is the desired result) in one window and add them to the exception in the next search?

unit Parser; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, OleCtrls, SHDocVw, ActiveX, XPMan, StrUtils, mmsystem, ExtCtrls, Menus; type TMainForm = class(TForm) BtnStart: TButton; WebBrowser1: TWebBrowser; Memo3: TMemo; XPManifest: TXPManifest; Memo2: TMemo; EditInterval: TEdit; Label2: TLabel; BtnLoad: TButton; BtnStop: TButton; Timer: TTimer; Edit1: TEdit; Label1: TLabel; MainMenu: TMainMenu; N1: TMenuItem; Memo1: TMemo; Edit3: TEdit; Label3: TLabel; Label4: TLabel; procedure Delay(const AMilliseconds: Cardinal); function ParseStr(str, sub1, sub2: string): tstrings; procedure BtnLoadClick(Sender: TObject); procedure BtnStartClick(Sender: TObject); procedure BtnStopClick(Sender: TObject); procedure N1Click(Sender: TObject); procedure Pars; procedure Search; procedure TimerTimer(Sender: TObject); private { Private declarations } public { Public declarations } end; var MainForm: TMainForm; Date: string; Used: array [0..1000] of boolean; Kol,KolOld: integer; implementation var Count: integer; {$R *.dfm} // ΠΏΡ€ΠΎΡ†Π΅Π΄ΡƒΡ€Π° Π·Π°Π΄Π΅Ρ€ΠΆΠΊΠΈ procedure TMainForm.Delay(const AMilliseconds: Cardinal); var SaveTickCount: Cardinal; begin SaveTickCount := GetTickCount; repeat Application.ProcessMessages; until GetTickCount - SaveTickCount > AMilliseconds; end; procedure TMainForm.N1Click(Sender: TObject); begin Application.Terminate; end; // поиск послСднСго вхоТдСния function PosR2L(const FindS, SrcS: string): Integer; function InvertS(const S: string): string; var i, Len: Integer; begin Len := Length(S); SetLength(Result, Len); for i := 1 to Len do Result[i] := S[Len - i + 1]; end; var ps: Integer; begin ps := Pos(InvertS(FindS), InvertS(SrcS)); if ps <> 0 then Result := Length(SrcS) - Length(FindS) - ps + 2 else Result := 0; end; // ΠΈΠ·Π²Π»Π΅Ρ‡Π΅Π½ΠΈΠ΅ тСкста ΠΌΠ΅ΠΆΠ΄Ρƒ Ρ‚Π΅Π³Π°ΠΌΠΈ function TMainForm.ParseStr(str, sub1, sub2: string): tstrings; var st,fin:Integer; begin Result:=TStringList.Create; repeat st:=Pos(sub1, str); if st > 0 then begin str:=Copy(str,st+length(sub1),length(str)-1); st:=1; fin:=Pos(sub2,str); Result.Add(Copy(str,st,fin-st)); str:=Copy(str,fin+length(sub2),length(str)-1); end; until st<=0; end; // ΠΏΡ€ΠΎΡ†Π΅Π΄ΡƒΡ€Π° ΠΏΠ΅Ρ€Π΅Π²ΠΎΠ΄Π° Π² HTML-ΠΊΠΎΠ΄ function WB_GetHTMLCode(WebBrowser: TWebBrowser; ACode: TStrings): Boolean; var ps: IPersistStreamInit; ss: TStringStream; sa: IStream; s: string; begin ps := WebBrowser.Document as IPersistStreamInit; s := ''; ss := TStringStream.Create(s); try sa := TStreamAdapter.Create(ss, soReference) as IStream; Result := Succeeded(ps.Save(sa, True)); if Result then ACode.Add(ss.Datastring); finally ss.Free; end; end; // Π‘Ρ‚Π°Ρ€Ρ‚ procedure TMainForm.BtnStartClick(Sender: TObject); var str:string; i: integer; begin for i:=0 to 1000 do used[i]:=False; Timer.Interval:=StrToInt(EditInterval.Text); Timer.Enabled:=True; end; // поиск ΠΈ очистка исходного ΠΊΠΎΠ΄Π° страницы для нахоТдСния счСта procedure TMainForm.Pars; var str:string; i: integer; var Opt: OleVariant; begin Opt:=2; WebBrowser1.Refresh2(Opt); Memo3.Clear; // ΠΈΠ·Π²Π»Π΅ΠΊΠ°ΠΌ исходный ΠΊΠΎΠ΄ Π·Π°Π³Ρ€ΡƒΠΆΠ΅Π½Π½ΠΎΠΉ страницы WB_GetHTMLCode(Webbrowser1, Memo3.Lines); Memo3.Text:=Utf8Decode(Memo3.Text); // удаляСм лишниС Ρ‚Π΅Π³ΠΈ ΠΈ ΠΊΠΎΠ΄ Π² счСтС Memo2.Lines:=ParseStr(Memo3.Text,'<div class="cl-left red">','</span>'); Memo2.Text:=StringReplace(Memo2.Text,'<span class="result-description-part">','',[rfReplaceAll]); Memo2.Text:=StringReplace(Memo2.Text,'<img class="sport-icon-image" src=','',[rfReplaceAll]); Memo1.Lines:=ParseStr(Memo2.Text,'https:','.png'); str:=Memo1.Lines[0]; Memo2.Text:=StringReplace(Memo2.Text,'https:'+str+'.png','',[rfReplaceAll]); Memo2.Text:=StringReplace(Memo2.Text,'"','',[rfReplaceAll]); Memo2.Text:=StringReplace(Memo2.Text,'/>','',[rfReplaceAll]); Memo2.Text:=StringReplace(Memo2.Text,' ','',[rfReplaceAll]); Kol:=Memo2.Lines.Count; end; // ΠΏΡ€ΠΎΡ†Π΅Π΄ΡƒΡ€Π° поиска счСта procedure TMainForm.Search; var i,p: integer; str: string; found: boolean; begin if Kol<>KolOld then for i:=0 to 1000 do used[i]:=False; found:=False; for i :=0 to Memo2.Lines.Count-1 do begin str:=Memo2.Lines[i]; p:=Pos('('+trim(Edit1.Text),str); if p=0 then p:=Pos('('+trim(Edit3.Text),str); // Ссли Π½Π°ΠΉΠ΄Π΅Π½ ΡƒΠΊΠ°Π·Π°Π½Π½Ρ‹ΠΉ счСт Π² ΠΏΠ΅Ρ€Π²ΠΎΠΌ сСтС if (p<>0) and (str[p-1]<>')') and (not found) and (NOT Used[i]) then begin found:=True; Timer.Enabled:=False; // Π²ΠΊΠ»ΡŽΡ‡Π°Π΅ΠΌ сигнал ΠΈ Π²Ρ‹Π²ΠΎΠ΄ΠΈΠΌ сообщСниС PlaySound(PChar(ExtractFilePath(ParamStr(0))+'beep.wav'),0,SND_FILENAME+SND_ASYNC ); ShowMessage('Π’Π°ΠΊΠΎΠΉ счСт Π½Π°ΠΉΠ΄Π΅Π½! '+Memo2.Lines[i]); // послС наТатия "Ок" ΠΎΡ‚Ρ‡ΠΊΠ»ΡŽΡ‡Π°Π΅ΠΌ ΡΠΈΠ³Π½Π°Π»ΠΈΠ·Π°Ρ†ΠΈΡŽ PlaySound(0, 0, SND_PURGE); Used[i]:=True; KolOld:=Kol; Timer.Enabled:=True; cv end; end; end; // ΠžΠ±Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° Ρ‚Π°ΠΉΠΌΠ΅Ρ€Π° procedure TMainForm.TimerTimer(Sender: TObject); begin Pars; Application.ProcessMessages; Search; Application.ProcessMessages; end; // остановка Ρ‚Π°ΠΉΠΌΠ΅Ρ€Π° procedure TMainForm.BtnStopClick(Sender: TObject); begin Timer.Enabled:=False; end; // Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠ° страницы procedure TMainForm.BtnLoadClick(Sender: TObject); begin Memo3.Clear; // Π³Ρ€ΡƒΠ·ΠΈΠΌ страницу Π² TWebBrowser WebBrowser1.Navigate('https://www.marathonbet.com/su/live/22723'); // ΠΎΠΆΠ΄ΠΈΠ°Π΅ΠΌ окончания Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠΈ страницы While WebBrowser1.Busy do Application.ProcessMessages; end; end. 

Closed due to the fact that the issue is too general for the participants Kromster , aleksandr barakin , Nick Volynkin ♦ , Peter Olson , Vladimir Glinskikh 27 Jul '15 at 3:32 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See β€œHow to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

    Here the program does not work with new windows. Just showing a MessageBox

    Here is a string

     ShowMessage('Π’Π°ΠΊΠΎΠΉ счСт Π½Π°ΠΉΠ΄Π΅Π½! '+Memo2.Lines[i]); 

    You just need to put one TListBox on the MainForm main form and output the results not ShowMessage but

     ListBox.Add('Π’Π°ΠΊΠΎΠΉ счСт Π½Π°ΠΉΠ΄Π΅Π½! '+Memo2.Lines[i]); 

    You will have all the messages in one list.