Autor Beitrag
O'rallY
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 563



BeitragVerfasst: So 15.06.03 20:32 
Ich suche eine möglichst kleine Lösung, um den Inhalt einer Internetseite auszulesen. Wenn ich die IdHTTP einbide, wird mein Projekt 200 KB größer, dabei brauche ich nur den Get-Befehl.

_________________
.oO'rallY
Linux is like a tipi: No gates, no windows and a gnu-eating apache inside...
SpeedyGTD
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 89



BeitragVerfasst: So 15.06.03 22:09 
gehört das nicht eigentlich ins Netzwerk Forum?
naja egal ;)
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
uses 
   ...UrlMon;

procedure TForm1.Saugwas();
begin
UrlDownloadToFile(...)
end;

_________________
...hab ich vergessen ;)
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mo 16.06.03 08:35 
kann man nicht nur die unit einbinden, die für das HTTP get da ist ?? ohne gleich die kompletten indys drin zu haben ??

PS: ich würde aber trotz den 200 kb INDY nehmen....

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Unzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 57



BeitragVerfasst: Mo 16.06.03 15:39 
Hallo,

Meineserachtens gibt es in Delphi Units, die enthalten Funktionen, und das kann man in der Regel nicht abändern. Wenn du allerdings irgendwo den Sourcecode der DCU-Datei hast, kopierst du dir einfach die Prozedur rüber. Oder du schreibst selbst eine. Hab jetzt nur keine Lust zu überlegen wie, geht aber bestimmt. Vielleicht können dir da andere helfen.

Gruß

Unzi
O'rallY Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 563



BeitragVerfasst: Mo 16.06.03 16:30 
Ich habe nun zwei Möglichkeiten herausgefunden, ans Ziel zu kommen:
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:
uses 
  WinInet, WinSock, Windows; 

function LoadURL(URL: String): String
var 
  IOpen, IURL: HINTERNET; 
  Read: Cardinal; 
  Msg: array[0..4096of Char; 
begin 
  Result := ''
  try 
    IOpen := InternetOpen('Mein Programm', INTERNET_OPEN_TYPE_PRECONFIG, ''''
        INTERNET_FLAG_NEED_FILE); 
    if IOpen <> nil then 
    try 
      IURL := InternetOpenUrl(IOpen, PAnsiChar(URL), nil0
          INTERNET_FLAG_NO_UI, 0); 
      if IURL <> nil then 
      try 
        repeat 
          FillChar(Msg, SizeOf(Msg), 0); 
          if InternetReadFile(IURL, @Msg[0], Pred(SizeOf(Msg)), Read) then 
            Result := Result + Msg 
          else 
            Break; 
        until Read = 0
      finally 
        InternetCloseHandle(IURL); 
      end
    finally 
      InternetCloseHandle(IOpen); 
    end
  except 
  end
end;

ausblenden 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:
uses 
  UrlMon; 

function GetPageContent(URL: string): string
var 
  MyFile: file
  Buf: array[0..14of Char; 
  Filename: string
  MyResult: integer; 
begin 
  Result := ''
  Filename := ExtractFilePath(ParamStr(0)) + 'temp.txt'
  UrlDownloadToFile(nil, PChar(URL), PChar(Filename), 0nil); 
  AssignFile(MyFile, Filename); 
  {$i-} 
  if Fileexists(Filename) then 
    Reset(MyFile) 
  else 
    ReWrite(MyFile); 
  {$I+} 
  if IOResult = 0 then 
    BlockRead(MyFile, Buf, SizeOf(Buf), MyResult); 
  CloseFile(MyFile); 
  DeleteFile(Filename); 
  Result := Buf; 
end;


Doch wenn die Seite nicht sofort ereicht werden kann, blockiert es mein ganzes Programm und versucht es immer weiter. Wie kann ich einen Timeout realisieren?

_________________
.oO'rallY
Linux is like a tipi: No gates, no windows and a gnu-eating apache inside...