Autor Beitrag
napsterforever
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73



BeitragVerfasst: Mo 24.08.09 18:02 
hallo,

wie kann ich am besten den Track aus folgendem HTML Code auslesen

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
<tbody>
    <tr class="rc_table_detail_alternative">
      <th style="width: 100%;">
                  Krid P - Bagpipes
              </th>
    </tr>

  </tbody>


Das Problem ist das vor und nach "Krid P - Bagpipes" kein code ist!

Wenn ich
ausblenden Quelltext
1:
2:
3:
4:
5:
<tr class="rc_table_detail_alternative">
      <th style="width: 100%;">
                  <a href="/release/various-artist/66/jump-bump-e-p-vol-5/">Interactive - Dildo 2008</a>
              </th>
    </tr>
habe, dann kann ich es ja auslesen:
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:
  .
  .
  .
  TrackPicStart := '/">';
  TrackPicEnd := '</a>';
  AText.Text := idhttp1.Get('http://www.technobase.fm/tracklist.php');

  for i:= 0 to AText.Count -1 do
  begin
  // search track start sequence
  FoundPos := Pos(TrackPicStart, AText.Text);
  if FoundPos = 0 then
    Exit;
  CurrentText := @AText.Text[FoundPos + Length(TrackPicStart)];
  // search track end
  FoundPos := Pos(TrackPicEnd, CurrentText);
  if FoundPos = 0 then
    Exit;
  ATrack := Copy(CurrentText, 1, FoundPos - 1);
  AText.Text := CurrentText;
  . 
  .
  .


Weil ich kann ja die genaue Position des Tracks mit TrackPicStart := '/">' und TrackPicEnd := '</a>' ermitteln, nur wie geht es in dem obigen Beispiel??!


Moderiert von user profile iconNarses: Topic aus VCL (Visual Component Library) verschoben am Mo 24.08.2009 um 18:35
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Mo 24.08.09 18:19 
Ich würde es so machen:
1. Alles zwischen <tr class="rc_table_detail_alternative"> und </tr> mit Pos, PosEx und Copy extrahieren. (um sicherzustellen das die richtige Tabellezeile kopiert wird)
2. Alles zwischen <th style="width: 100%;"> und </th> extrahieren
3. Noch ein Trim(DeineVariable) um die Leerzeichen zu entfernen und fertig. Wo liegt das Problem?
napsterforever Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73



BeitragVerfasst: Mo 24.08.09 18:45 
ja wie genau meinst du das :D
ich stehe auf dem schlauch

EDIT:

oh man, habs hinbekommen :D
geht im Grunde genauso, habe nur <th style="width: 100%;"> wieder mal falsch in delphi übertragen, so dass er es nicht finden konnte, flüchtigkeitsfehler :twisted:

EDIT2:

sooo, fertig

--> link