Autor Beitrag
tilli1980
Hält's aus hier
Beiträge: 14

WIN XP SP2
D7 Prof
BeitragVerfasst: So 13.03.05 13:52 
Hallo zusammen

Ich arbeite sehr viel mit der TwebBrowser-Komponente. Da ich ein Programm programiert habe welches ein große Internet-Link Sammlung beinhaltet die über die TWebBrowser Komponente angezeigt wird, wollte ich ein Programm programieren welches jeden Link überprüft ob er noch existiert oder ob er tot ist. Wie stelle ich es am besten an.

Bin für jede Hilfe dankbar :D

Gruß tilli1980
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: So 13.03.05 13:54 
Dafür kannst du TIdHTTP (Indy) benutzen und den Response Code (404 bzw. 200) auswerten.

_________________
Ciao, Sprint.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 13.03.05 13:55 
wenn der server mit einer 404 nachricht antwortet wenn du die entsprechende seite requestest, so ist der link tot.
Suche bei Google RFC HTTP 404

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
tilli1980 Threadstarter
Hält's aus hier
Beiträge: 14

WIN XP SP2
D7 Prof
BeitragVerfasst: So 13.03.05 14:09 
aha, habe noch nicht mit den Indy-Komponenten gearbeitet. Wie müßte das Beispiel mit www.web.de und der Label-Komponente ausehen?
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 13.03.05 14:21 
was für ein bleistift ? :gruebel:

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: So 13.03.05 14:32 
Hallo,

schau mal dort:
Prüfen, ob Datei im Internet existiert
MfG
Lannes
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: So 13.03.05 14:50 
tilli1980 hat folgendes geschrieben:
aha, habe noch nicht mit den Indy-Komponenten gearbeitet.

ausblenden Delphi-Quelltext
1:
2:
uses
  IdHTTP

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
function IsLinkAvailable(const AURL: String): Boolean;
begin

  Result := False;
  with TIdHTTP.Create(nil) do
    try
      try
        Head(AURL);
        case ResponseCode of
          200: Result := True;
        end;
      except
      end;
    finally
      Free;
    end;

end;

_________________
Ciao, Sprint.
tilli1980 Threadstarter
Hält's aus hier
Beiträge: 14

WIN XP SP2
D7 Prof
BeitragVerfasst: So 13.03.05 14:52 
Danke für den tip :D

Werde gleich mal probieren
tilli1980 Threadstarter
Hält's aus hier
Beiträge: 14

WIN XP SP2
D7 Prof
BeitragVerfasst: So 13.03.05 15:13 
Habe es ausprobiert. Bekomme aber ein Fehler. Irgendetwas mit socket. Verbíndung abgelehnt.

Hier ist mein Code. Wo ist der Fehler?

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdHTTP;

type
  TForm1 = class(TForm)
    IdHTTP1: TIdHTTP;
    Button1: TButton;
    Label1: TLabel;

    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


function IsLinkAvailable(const AURL: String): Boolean;
begin


  Result := False;
  with TIdHTTP.Create(nil) do
    try
      try
        Head(AURL);
        case ResponseCode of
          200: Result := True;
        end;  
      except
      end;
    finally
      Free;
    end;
    End;





procedure TForm1.Button1Click(Sender: TObject);
begin
if islinkavailable('www.web.de') then label1.Caption:= 'ok'
else
label1.Caption:= 'falsch';
end;



end.


Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: So 13.03.05 15:16 
tilli1980 hat folgendes geschrieben:
Habe es ausprobiert. Bekomme aber ein Fehler. Irgendetwas mit socket. Verbíndung abgelehnt.

Das ist okay. Dieser Fehler wird nur im Debug Modus angezeigt.

_________________
Ciao, Sprint.
tilli1980 Threadstarter
Hält's aus hier
Beiträge: 14

WIN XP SP2
D7 Prof
BeitragVerfasst: So 13.03.05 15:31 
Du hast recht. Habe es mal ohne Debugger ausgeführt. Aber müßte er dann bei mein Quellcode bei "www.web.de" nicht "ok" anzeigen. Weil er immer falsch anzeigt. Oder habe ich ein Schreibfehler?
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 13.03.05 15:37 
eine url beginnt normalerweise mit HTTP://

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
tilli1980 Threadstarter
Hält's aus hier
Beiträge: 14

WIN XP SP2
D7 Prof
BeitragVerfasst: So 13.03.05 15:43 
user profile iconretnyg hat folgendes geschrieben:
eine url beginnt normalerweise mit HTTP://



Habe es auch mit Http ausprobiert. da kommt der selbe Fehler
tilli1980 Threadstarter
Hält's aus hier
Beiträge: 14

WIN XP SP2
D7 Prof
BeitragVerfasst: So 13.03.05 16:34 
user profile iconLannes hat folgendes geschrieben:
Hallo,

schau mal dort:
Prüfen, ob Datei im Internet existiert
MfG
Lannes


So ich habe mal diese Variante mal ausprobiert.

Diese Variante funtioniert wunderbar, Ohne Verzögerung. kann damit auch prima mehrere Links abfragen. Die fehlerhaften Links hat er auch gemeistert.

:D :D :D

Super, danke für eure Hilfe