Jump to content

clubreseau

Members
  • Content Count

    33
  • Joined

  • Last visited

Everything posted by clubreseau

  1. clubreseau

    Need help with IDhttp and Thread

    I have published elsewhere precisely to not ask you too much.
  2. clubreseau

    Need help with IDhttp and Thread

    Yes I use all platform to get help.
  3. clubreseau

    Need help with IDhttp and Thread

    I try with function TThreadPool.ShouldGrowPool: Boolean; begin Result := {(FWorkerThreadCount < FMinLimitWorkerThreadCount) and }(FIdleWorkerThreadCount < FQueuedRequestCount) and (FWorkerThreadCount < Self.FMaxLimitWorkerThreadCount); end;
  4. clubreseau

    Need help with IDhttp and Thread

    Ok TThreadPool hard to implement on the code.
  5. clubreseau

    Need help with IDhttp and Thread

    Ok for me the second option is better for me. Only 1 problem, if my listbox contain 100 urls, going to 100 urls at the same time, this is make page time out. How I can proced with 5 or 10 url at time ?
  6. clubreseau

    Need help with IDhttp and Thread

    Wow Thank you Remy Lebeau for your time, Thank you for this documentation. What more could you ask for a well documented example. I'll read it to get it right, then try to build a loop with your explanations. Thank you again for all this help.
  7. clubreseau

    Need help with IDhttp and Thread

    TParallel.For() can you show me how ? for what I want ! thank you I try this and its freeze my delphi TParallel.&For(1,10, procedure(Index: Integer) begin TThread.Synchronize(TThread.CurrentThread, procedure begin Form1.Caption := 'Task Starting...'; end); end); I try this and work TThread.Queue(TThread.CurrentThread, procedure begin Form1.Caption := 'Task Starting...'; end); end why Synchronize freeze and not Queue ? then for what I want I need to use only Queue ? ALso I try this procedure TForm1.Button1Click(Sender: TObject); begin TParallel.&For(0, ListBox1.Items.Count-1, procedure(AIndex: Integer) var lPath: string; lHTTP: TIdHTTP; IdSSL: TIdSSLIOHandlerSocketOpenSSL; URI: TIdURI; begin TThread.Queue(nil, procedure begin Form1.Caption := 'Task Starting...'; lPath := ListBox1.Items.Strings[AIndex]; end); lHTTP := TIdHTTP.Create(nil); try lHTTP.ReadTimeout := 30000; lHTTP.HandleRedirects := True; IdSSL := TIdSSLIOHandlerSocketOpenSSL.Create(lHTTP); IdSSL.SSLOptions.SSLVersions:= [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2]; IdSSL.SSLOptions.Mode := sslmClient; lHTTP.IOHandler := IdSSL; lHTTP.AllowCookies:=true; lHTTP.Request.UserAgent := 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36'; lHTTP.Request.Accept := 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; lHTTP.Request.AcceptLanguage := 'en-GB,en;q=0.5'; lHTTP.Request.Connection := 'keep-alive'; lHTTP.Request.ContentType := 'application/x-www-form-urlencoded'; lHTTP.Get(lPath); except on E: EIdHTTPProtocolException do begin if E.ErrorCode = 404 then begin TThread.Synchronize(nil, procedure begin Form1.ListBox2.Items.Add(lPath); end ); end; Exit; end; end; TThread.Queue(nil, procedure begin Form1.Memo1.Lines.Add(lPath); end ); end ); end; this code give me error 1 or more error 0 exception(s); if I click again I got this error: error 1 or more error 1 exception(s); #0 EldUnknownProtocol: UnknownProtocol
  8. clubreseau

    Need help with IDhttp and Thread

    I use this code and it work procedure TForm1.Button1Click(Sender: TObject); var i:integer; lpath:string; begin for i := 0 to ListBox1.Items.Count-1 do begin lPath := ListBox1.Items.Strings[i]; download(lPath); end; end; procedure TForm1.Download(lpath: string); begin TTask.Create( procedure var HTTP : TidHTTP; IdSSL: TIdSSLIOHandlerSocketOpenSSL; content : String; URI: TIdURI; fmatch : TMatchCollection; regex2 : TRegEx; fmatchcount:string; begin HTTP := TIdHTTP.Create(nil); try HTTP.ReadTimeout := 30000; HTTP.HandleRedirects := True; IdSSL := TIdSSLIOHandlerSocketOpenSSL.Create(HTTP); IdSSL.SSLOptions.Method := sslvTLSv1_2; IdSSL.SSLOptions.Mode := sslmClient; HTTP.IOHandler := IdSSL; HTTP.AllowCookies:=true; HTTP.Request.UserAgent := 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36'; HTTP.Request.Accept := 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; HTTP.Request.AcceptLanguage := 'en-GB,en;q=0.5'; HTTP.Request.Connection := 'keep-alive'; HTTP.Request.ContentType := 'application/x-www-form-urlencoded'; HTTP.CookieManager := TIdCookieManager.Create(HTTP); URI := TIdURI.Create('http://localhost'); try HTTP.CookieManager.AddServerCookie('habari=10283454', URI); finally URI.Free; end; Content := HTTP.Get(lpath); finally TThread.queue(TThread.Current, procedure begin regex2 := TRegEx.Create('Welcome', [roIgnoreCase]); fmatch := regex2.Matches(Content); fmatchcount:=IntToStr(fmatch.Count); if fmatchcount > '0' then listbox2.items.Add(lpath); //listbox2.Items.Add(lpath); end); end; end ).Start; end; Like this its slow how to past the 100 urls in my listbox faster ?
×