Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Wyciecie z HTML
rad11
post 11.05.2015, 09:35:55
Post #1





Grupa: Zarejestrowani
Postów: 1 270
Pomógł: 184
Dołączył: 7.10.2012
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Witam panowie potrzebuje wyciac z HTML`a pomiedzy <div class="feedbacksSummary roundCornerWhiteBG corAll5"> tabele:

  1. <div class="feedbacksSummary roundCornerWhiteBG corAll5">
  2. <table cellspacing="0">
  3. <thead>
  4. <tr>
  5. <td>&#1054;ценка</td>
  6. <td>&#1055;оследние <br>7 дней</td>
  7. <td>&#1055;оследние <br>30 дней</td>
  8. <td>&#1042;се</td>
  9. <td>&#1050;упил/Продал</td>
  10. </tr>
  11. </thead>
  12. <tbody>
  13. <tr class="pos">
  14. <td class="rowName">&#1055;оложительные</td>
  15. <td>1</td>
  16. <td>2</td>
  17. <td>481</td>
  18. <td>3 / 478</td>
  19. </tr>
  20. <tr class="neu">
  21. <td class="rowName">&#1053;ейтральные</td>
  22. <td>0</td>
  23. <td>0</td>
  24. <td>1</td>
  25. <td>0 / 1</td>
  26.  
  27. </tr>
  28. <tr class="neg">
  29. <td class="rowName">&#1054;трицательные</td>
  30. <td>0</td>
  31. <td>0</td>
  32. <td>3</td>
  33. <td>0 / 3</td>
  34. </tr>
  35. </tbody>
  36. </table>
  37. </div>


Jakies pomysly jakie uzyc wyrazenie?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 6)
viking
post 11.05.2015, 09:39:10
Post #2





Grupa: Zarejestrowani
Postów: 6 378
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


http://simplehtmldom.sourceforge.net/


--------------------
Go to the top of the page
+Quote Post
rad11
post 11.05.2015, 11:07:31
Post #3





Grupa: Zarejestrowani
Postów: 1 270
Pomógł: 184
Dołączył: 7.10.2012
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Wolalbym uzyc do tego albo dom document albo uzyc swojego jednego wyrazenia. Probowalem w ten sposob:

  1. preg_match_all("|<div class='feedbacksSummary roundCornerWhiteBG corAll5'>(.*)</div>|U",$html,$out, PREG_PATTERN_ORDER);


ale nie idzie

Ten post edytował rad11 11.05.2015, 11:17:23
Go to the top of the page
+Quote Post
viking
post 11.05.2015, 11:17:55
Post #4





Grupa: Zarejestrowani
Postów: 6 378
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


A co jak np klasy będą miały inną kolejność? Masz jeszcze http://php.net/manual/en/book.simplexml.php
Generalnie masz XML, HTML nie operuj regexpami bo to się prosi o kłopoty.


--------------------
Go to the top of the page
+Quote Post
lukasz1985
post 11.05.2015, 13:51:25
Post #5





Grupa: Zarejestrowani
Postów: 205
Pomógł: 43
Dołączył: 5.03.2012

Ostrzeżenie: (0%)
-----


http://stackoverflow.com/questions/1732348...-contained-tags
Go to the top of the page
+Quote Post
patwoj98
post 11.05.2015, 19:52:21
Post #6





Grupa: Zarejestrowani
Postów: 218
Pomógł: 16
Dołączył: 6.06.2014
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Łap tu na 2 explode oparte:
  1. $zmienna = '<div class="feedbacksSummary roundCornerWhiteBG corAll5">
  2. <table cellspacing="0">
  3. <thead>
  4. <tr>
  5. <td>Оценка</td>
  6. <td>Последние <br>7 дней</td>
  7. <td>Последние <br>30 дней</td>
  8. <td>Все</td>
  9. <td>Купил/Продал</td>
  10. </tr>
  11. </thead>
  12. <tbody>
  13. <tr class="pos">
  14. <td class="rowName">Положительные</td>
  15. <td>1</td>
  16. <td>2</td>
  17. <td>481</td>
  18. <td>3 / 478</td>
  19. </tr>
  20. <tr class="neu">
  21. <td class="rowName">Нейтральные</td>
  22. <td>0</td>
  23. <td>0</td>
  24. <td>1</td>
  25. <td>0 / 1</td>
  26.  
  27. </tr>
  28. <tr class="neg">
  29. <td class="rowName">Отрицательные</td>
  30. <td>0</td>
  31. <td>0</td>
  32. <td>3</td>
  33. <td>0 / 3</td>
  34. </tr>
  35. </tbody>
  36. </table>
  37. </div>';
  38.  
  39. $wynik = explode('<div class="feedbacksSummary roundCornerWhiteBG corAll5">',$zmienna);
  40. $koncowy = explode("</div>",$wynik[1]);
  41. echo $koncowy[0];


Ten post edytował patwoj98 11.05.2015, 19:52:38
Go to the top of the page
+Quote Post
robertpiaty
post 12.05.2015, 20:58:16
Post #7





Grupa: Zarejestrowani
Postów: 113
Pomógł: 18
Dołączył: 7.10.2007
Skąd: Pruszków

Ostrzeżenie: (0%)
-----


Nie upieraj się przy wyrażeniach, bo ktoś Ci zrobi małą modyfikację html-a np. pomiędzy Twoim div-em a tabelą doda jeszcze jednego div-a i wszystko leży.
Spróbuj tego http://php.net/manual/en/domdocument.loadhtml.php a potem użyj xpath


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 18.07.2025 - 15:07