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.