Autor Beitrag
Silvia
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Fr 01.04.05 15:19 
Hallo,

ich möchte eine Webseite aufrufen und im suchfeld eine ISBN eingeben die wiederum in einer Access Datenbank abgelegt ist und von dieser Seite das Bild zur dazugehörigen ISBN speichert!

Hat jemand sowas schonmal gesehen oder gemacht?
fvolk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 203

Win XP (Home & Pro)
Delphi 2005 Pers
BeitragVerfasst: Fr 01.04.05 15:35 
Ich vermute mal, auf der Webseite wird dann das Bild des Buches/der CD angezeigt, wenn du per Suche die ISBN übergeben hast.

Also, such dir raus, wie du die ISBN an die Seite übergeben musst, ruf' die entsprechende Url mit der TidHTTP-Komponente aus den Indys auf: idhttp.Get(URL);. Dann hast du schonmal den Quelltext der Webseite.

Dann informiere dich, wo im Quelltext der <img..>-Tag liegt, der das Bild anzeigt und extrahiere dessen src=""-Information. Damit hast du die Adresse des entsprechenden Bildes, welches du nur noch herunterladen musst. Entweder wieder mit idhttp.Get() oder mit Suche in: Delphi-Forum, Delphi-Library DATEI HERUNTERLADEN.

Ich hoffe, das war nicht zu konfus.

_________________
Nichts auf der Welt ist so gerecht verteilt wie der Verstand. Denn jedermann ist überzeugt, dass er genug davon habe.
(René Descartes)
Silvia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Fr 01.04.05 16:32 
Okay,

hab mir den Quelltext in eine Textdatei gespeichert und jetzt möchte ich nach dem entsprechenden eintrag suchen und den dazugehörigen Link des Bildes aufrufen und downloden!
Wie macht man das?
Silvia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Fr 01.04.05 16:34 
Achso,

mein Quelltext sieht so aus!
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:
27:
28:
29:
30:
rocedure TForm1.Button4Click(Sender: TObject);
var isbn : string;
begin
// hier soll die ISBN aus der Datenbank eingelesen werden!
isbn := '3404261380';
// zeigt die gefundenen Bilder an!
WebBrowser1.Navigate('http://images.google.de/images?hl=de&lr=&q='+isbn);
end;
//------------------------------------------------------------------------------
procedure TForm1.Button5Click(Sender: TObject);
begin
  WB_SaveHTMLCode(Webbrowser1, 'c:\test.txt');
end;
//------------------------------------------------------------------------------
function WB_SaveHTMLCode(WebBrowser: TWebBrowser; const FileName: TFileName): Boolean;
var
  ps: IPersistStreamInit;
  fs: TFileStream;
  sa: IStream;
begin

  ps := WebBrowser.Document as IPersistStreamInit;
  fs := TFileStream.Create(FileName, fmCreate);
  try
    sa := TStreamAdapter.Create(fs, soReference) as IStream;
    Result := Succeeded(ps.Save(sa, True));
  finally
    fs.Free;
  end;
end;


Moderiert von user profile iconAXMD: Code- durch Delphi-Tags ersetzt.
fvolk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 203

Win XP (Home & Pro)
Delphi 2005 Pers
BeitragVerfasst: Fr 01.04.05 21:27 
Naja, schau ihn dir an, und versuche herauszufinden, wie du das <img...>-Tag findest, das für die Anzeige deiner Graphik (also der entsprechenden) verantwortlich ist.

Dann isolierst du die Url innerhalb dieses Tags mit Hilfe der String-Funktionen von Delphi (z.B. Pos, Copy, Delete...)

_________________
Nichts auf der Welt ist so gerecht verteilt wie der Verstand. Denn jedermann ist überzeugt, dass er genug davon habe.
(René Descartes)
Silvia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Sa 02.04.05 11:12 
Soweit so Gut!

ich habe die Index Position von der ich bis zum nächsten & Zeichen alle daraffolgenden Zeichen auslesen möchte!
Also:

ich durchsuche den Quelltext bis zum Eintrag "imgurl" der link endet mit dem Zeichen "&". Den pos Index habe ich wie lese ich die nächsten zeichen bis zum & aus?
delphist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN XP, 98, 95; SUSE LINUX 8.1, 6.1, 6.0

BeitragVerfasst: Sa 02.04.05 11:39 
user profile iconSilvia hat folgendes geschrieben:
ich durchsuche den Quelltext bis zum Eintrag "imgurl" der link endet mit dem Zeichen "&". Den pos Index habe ich wie lese ich die nächsten zeichen bis zum & aus?


ausblenden Quelltext
1:
2:
function Copy(S; Index, Count: Integer): string;
function Copy(S; Index, Count: Integer): array;

Erzeugt einen Teilstring aus dem String S.

Viel Spass!

_________________
3w + freehostlist + de
3w + bild-stoerung + de
Silvia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Sa 02.04.05 11:40 
Okay, hab es geschafft!

Ich habe einfach nochmal suchen lassen mit pos bis zum & Zeichen!
delphist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

WIN XP, 98, 95; SUSE LINUX 8.1, 6.1, 6.0

BeitragVerfasst: Sa 02.04.05 11:54 
willst du das programm oder zumindest den sourcecode posten?
könnte vielleicht für andere personen von nützen sein?
Gruss delphist

_________________
3w + freehostlist + de
3w + bild-stoerung + de
Silvia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Sa 02.04.05 12:10 
Na, klar!

Ich bin aber Neuling und der Source ist nicht Perfekt!
Für mich ist das Ziel wichtig und nicht der Weg!

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:
begin
// hier soll die ISBN aus der Datenbank eingelesen werden!
isbn := '3404261321';
// zeigt die gefundenen Bilder an!
WebBrowser1.Navigate('http://images.google.de/images?hl=de&lr=&q='+isbn+'.jpg');
url := 'http://images.google.de/images?hl=de&lr=&q='+isbn+'.jpg';
download(url,'C:\test.txt');
if FileExists('C:\test.txt'then
  begin
    sl:=TStringList.Create;
    sl.LoadFromFile('C:\test.txt');
    try
      // nach dem gewünschten Begriff suchen
      x:=System.Pos('imgurl', sl.Text);
      if (x>0then
      begin
        // Ende des aktuellen Eintrags löschen
        sl.Text:=System.Copy(sl.Text, x+7, x);
        x:=System.Pos('&', sl.Text);
        if (x>0then
        begin
          // geänderte Liste als gleiche Datei speichern
          sl.Text:=System.Copy(sl.Text, 1, x-1);
          download(sl.text,'C:\'+isbn+'.jpg');
        end;
      end;
    finally
      sl.Free;
    end// try
  end else ShowMessage(Format('Datei "%s" nicht gefunden!!', ['C:\test.txt']));
end;


Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt
Ivo@CoMRoK
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 258

Win XP
D3 Prof., D7 Pe.
BeitragVerfasst: Mo 06.02.06 21:50 
Ähm darf ich fragen?
Du verwendest da den Befehl:
ausblenden Delphi-Quelltext
1:
download(sl.text,'C:\'+isbn+'.jpg');					

is des aus Indy (Ich hab D3 und von Indy 0 Ahnung) oder welche Unit muss ich ins uses schreiben?

_________________
Fällt der Bauer tot vom Traktor, stand am Waldrand ein Reaktor.
Ein altes indianisches Sprichwort besagt:Es kann gefährlich sein gelben Schnee zu essen.
Silvia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Di 07.02.06 10:07 
Das sollte Dir weiterhelfen!!

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, OleCtrls, ActiveX, URLMon, SHDocVw,
Menus, DB, ADODB, Mask, DBCtrls, StrUtils;
Horst_H
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1654
Erhaltene Danke: 244

WIN10,PuppyLinux
FreePascal,Lazarus
BeitragVerfasst: Di 07.02.06 11:02 
Hallo,

ausblenden Delphi-Quelltext
1:
 download(sl.text,'C:\'+isbn+'.jpg');					

Ist etwas gefaehrlich.In WIn98 FAT32 sind nur maximal ~65000 Dateien in einem Ordner moeglich und bei langen Dateinamen entsprechend weniger(Bei mit war bei knapp ueber 31000 Schluss).Selbst NTFS ist dann lahm.
Jetzt sind es 220000 Dateien schoen gleichmaessig verteilt auf 530 Ordner.

Gruss Horst