Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Pobieranie danych ze strony
Forum PHP.pl > Forum > PHP
marcinvx
  1. <table cellpadding="0" cellspacing="0" align="center" rules="all">
  2. <tr>
  3. <td width="320"><b>Prezenter:</b> <span class="stream_genre"></span></td>
  4.  
  5. <td rowspan="2" width="80" height="36" align="center"><b>Słuchaczy:<br /><font size="3"><span class="stream_slucha"></span></font></b></td>
  6. </tr>
  7. <tr>
  8. <td><b>Audycja:</b> <span class="stream_title">B-Day ^^</span></td>
  9. </tr>
  10. </table>

Pobieranie danych pomiędzy <td><b>Audycja:</b> <span class="stream_title"> a </span></td> Czyli chciałbym aby na stronie wyświetlało się B-Day Party ^^
Jak zrobić ?
Ja nic nie mogę znaleźć. ;/
Gribo
możesz to zrobić na kilka sposobów:
-wyrażenie regularne
-xpath
-jeśli nie umiesz obydwu rozwiązań możesz zainteresować się biblioteką "PHP Simple HTML DOM"
jaslanin
  1. <pre>
  2. <?
  3.  
  4. $html = '
  5. <table cellpadding="0" cellspacing="0" align="center" rules="all">
  6. <tr>
  7. <td width="320"><b>Prezenter:</b> <span class="stream_genre"></span></td>
  8.  
  9. <td rowspan="2" width="80" height="36" align="center"><b>Słuchaczy:<br /><font size="3"><span class="stream_slucha"></span></font></b></td>
  10. </tr>
  11. <tr>
  12. <td><b>Audycja:</b> <span class="stream_title">B-Day ^^</span></td>
  13. </tr>
  14. </table>
  15. ';
  16.  
  17. preg_match_all("#Audycja.*stream_title.*>(.+)<#isU", $html, $matchesarray);
  18.  
  19. print_r($matchesarray);
  20.  
  21. ?>
  22. </pre>
marcinvx
To nie bedzie działać bo nie ma jak. ;/


  1. <table cellpadding="0" cellspacing="0" align="center" rules="all">
  2. <tr>
  3. <td width="320"><b>Prezenter:</b> <span class="stream_genre"></span></td>
  4. <td rowspan="2" width="80" height="36" align="center"><b>Słuchaczy:<br /><font size="3"><span class="stream_slucha"></span></font></b></td>
  5. </tr>
  6. <tr>
  7. <td><b>Audycja:</b> <span class="stream_title">B-Day ^^</span></td>
  8. </tr>
  9. </table>

To jest tylko fragment kodu ze strony:
  1. http://eradia.pl/script/player.php?id=13506&cmd=home

i chcę na swojej stronie wyświetlać dane o tym co teraz leci za piosenka w tym radiu.
jaslanin
działa.

  1. <pre>
  2. <?
  3.  
  4. preg_match_all("#Audycja.*stream_title.*>(.+)<#isU", file_get_contents("http://eradia.net/script/player.php?id=13506&cmd=home"), $matchesarray);
  5.  
  6. print_r($matchesarray);
  7.  
  8. ?>
  9. </pre>
marcinvx
  1. (
  2. [0] => Array
  3. (
  4. [0] => Audycja: DanceMusicParty.<
  5. )
  6.  
  7. [1] => Array
  8. (
  9. [0] => DanceMusicParty.
  10. )
  11.  
  12. )


questionmark.gif I Co dalej ? Jak zrobić zeby wyświetlało tylko "DanceMusicParty." questionmark.gif
Co to narazie wyszlo mozesz zobaczyc:
  1. http://gold-racing.pl/radio.php
jaslanin
Musisz wykazać trochę inicjatywy i sam to zrobić, tu masz trochę kursów jak się operuje na tablicy:

http://www.google.pl/search?hl=pl&biw=...mp;aql=&oq=
http://www.google.pl/search?hl=pl&biw=...mp;aql=&oq=
http://www.google.pl/search?hl=pl&biw=...mp;aql=&oq=
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.