Article View: pl.comp.lang.pascal
Article #92519[Lazarus] TCurl zawiesza się. Pomocy! Proszę!
From: Terrmit
Date: Tue, 01 Apr 2008 08:14
Date: Tue, 01 Apr 2008 08:14
63 lines
3007 bytes
3007 bytes
Witam,
Próbuję użyć komponentu TCurl z biblioteki lazcurl, wszystko niby
pięknie działa, ale TCurl zawiesza się dokładnie po 300-stu
wywołaniach TCurl.Perform. Pobieram 300 stron html i koniec.
Zrobiłem testową procedurkę, aby wybadać problem, ale nie mogę
dojść w czym rzecz, dlatego proszę Was o pomoc.
Procedura ma pobrać 500 razy stronę googli, ale zawiesza się
po 300. To wygląda tak, jakby jakaś zmienna lub jakiś stos
się przepełniał, może więc powinienem coś zrobić jeszcze
w tej pętli? Może ma ktoś jakiś pomysł?
<code>
procedure TForm1.gCurlReceive(Sender: TObject; data: PChar; len:
Cardinal; var bContinue: Boolean);
begin
TMemoryStream(TCurl(Sender).OutputStream).Write(data^, len);
end;
procedure TForm1.gCurlWait(Sender: TObject);
begin
Application.ProcessMessages;
end;
procedure TForm1.Button1Click(Sender: TObject);
var strona: String;
i: Integer;
gCurl: TCurl;
HtmlStream:TMemoryStream;
begin
gCurl := TCurl.Create(Self);
gCurl.ConnectTimeout := 15;
gCurl.Timeout := 60;
gCurl.Threaded := True;
gCurl.UserAgent := 'Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)';
gCurl.CookieFile:='google.txt';
gCurl.CookieSession:=True;
gCurl.OnWait := @gCurlWait;
gCurl.OnReceive:= @gCurlReceive;
gCurl.MaxConnects:=1;
gCurl.URL := 'http://www.google.pl/';
for i:=1 to 500 do begin
HtmlStream:=TMemoryStream.Create; //utworz strumien dla strony
try
gCurl.OutputStream:=HtmlStream; //przydzielenie strumienia
if gCurl.Perform then begin //Success... ale
//po 300 razach program zapetla sie (wisi) na tym Perform
//HtmlStream.Position := 0;
//strona := StreamToString(HtmlStream);
StatusBar1.Panels.Items[0].Text := 'OK '+IntToStr(i);
end else ShowMessage('Błąd pobierania strony!');
gCurl.ResultCode; //po bledzie ma przywracac stan CURLE_OK
finally
HtmlStream.Free;
end;
end;
gCurl.Free;
end;
</code>
Sławek
P.S. Lazarus 0.9.25 svn 14688, curlpas-2005-11-05,
curl-7.17.1-2.fc8.i386, System Fedora 8
Technical Details
Message-ID:
<fssr03$k01$1@atlantis.news.neostrada.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news2.icm.edu.pl!newsfeed.tpinternet.pl!newsfeed.neostrada.pl!atlantis.news.neostrada.pl!news.neostrada.pl!news.tpi.pl!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news2.icm.edu.pl!newsfeed.tpinternet.pl!newsfeed.neostrada.pl!atlantis.news.neostrada.pl!news.neostrada.pl!news.tpi.pl!not-for-mail From: Terrmit <terrmitv@poczta.onet.pl> Newsgroups: pl.comp.lang.pascal Subject: [Lazarus] TCurl zawiesza się. Pomocy! Proszę! Date: Tue, 01 Apr 2008 10:14:43 +0200 Organization: TP - http://www.tp.pl/ Lines: 63 Message-ID: <fssr03$k01$1@atlantis.news.neostrada.pl> NNTP-Posting-Host: fge166.internetdsl.tpnet.pl Mime-Version: 1.0 X-Trace: atlantis.news.neostrada.pl 1207037763 20481 83.13.160.166 (1 Apr 2008 08:16:03 GMT) X-Complaints-To: usenet@tpi.pl NNTP-Posting-Date: Tue, 1 Apr 2008 08:16:03 +0000 (UTC) User-Agent: Thunderbird 2.0.0.12 (X11/20080226) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit