Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]preg_match_all
Mades
post 21.09.2013, 10:44:13
Post #1





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 3.08.2013

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


Piszę drobny skrypt, który łączy się ze stroną i wyświetla wszystkie linki, które znajdują się na tej stronie. Lecz mam drobny problem.
Wszystko w zasadzie działa już jak należy, lecz chcę zmienić jedną rzecz, z którą nie mogę sobie poradzić.

Kawałek kodu strony:
  1. <tr id="s"><th id="sflag"><img src="http://img-cdn4.otservlist.org/flags/pr.png" alt="pr"/></th><th><a href="/ots/1451959">wodbkopr.sytes.net</a></th><th>WoDBO PR and DBKO PR</th><th>12 (72) / 120</th><th>60.82%</th><th>107</tdh><th>x500</th><th>PVP</th><th>[ 7.1 ]</th></tr>
  2. <tr id="s"><th id="sflag"><a href="http://brazil.otservlist.org"><img src="http://img-cdn4.otservlist.org/flags/br.png" alt="brazil Otserv"/></th><th><a href="/ots/1452857">emperia-online.servegam...</a></th><th>CLIENTE PROPRIO</th><th>0 (11) / 150</th><th>68.32%</th><th>118</tdh><th>x1</th><th>PVP</th><th>[ 7.1 ]</th></tr>


Chciałbym, aby wyświetlało tylko i jedynie "wodbkopr.sytes.net" + wszystkie pozostałe adresy. Obecnie wyświetla wszystkie linki do obrazków, stron itd. co mi nie odpowiada, ponieważ jest zbyt duży harmider.
  1. preg_match_all('/href="([^"]*)"/',$wynik,$kliklink);


Na większym przykładzie:
  1. <tr id="s"><th id="sflag"><img src="http://img-cdn4.otservlist.org/flags/pr.png" alt="pr"/></th><th><a href="/ots/1451959">wodbkopr.sytes.net</a></th><th>WoDBO PR and DBKO PR</th><th>12 (72) / 120</th><th>60.82%</th><th>107</tdh><th>x500</th><th>PVP</th><th>[ 7.1 ]</th></tr>
  2. <tr id="s"><th id="sflag"><a href="http://brazil.otservlist.org"><img src="http://img-cdn4.otservlist.org/flags/br.png" alt="brazil Otserv"/></th><th><a href="/ots/1452857">emperia-online.servegam...</a></th><th>CLIENTE PROPRIO</th><th>0 (11) / 150</th><th>68.32%</th><th>118</tdh><th>x1</th><th>PVP</th><th>[ 7.1 ]</th></tr>
  3. <tr id="s"><th id="sflag"><a href="http://brazil.otservlist.org"><img src="http://img-cdn4.otservlist.org/flags/br.png" alt="brazil Otserv"/></th><th><a href="/ots/1469325">thunderot.servegame.com</a></th><th>NEW POKEMON ONLINE</th><th>26 (112) / 700</th><th>99.71%</th><th>135</tdh><th>x50</th><th>FUN</th><th>[ 7.1 ]</th></tr>
  4. <tr id="s"><th id="sflag"><a href="http://brazil.otservlist.org"><img src="http://img-cdn4.otservlist.org/flags/br.png" alt="brazil Otserv"/></th><th><a href="/ots/1471254">baiakiice2013.servegame...</a></th><th>Baiak Dedicado</th><th>0 (11) / 841</th><th>41.39%</th><th>67</tdh><th>x999</th><th>PVP</th><th>[ 7.1 ]</th></tr>
  5. <tr id="s"><th id="sflag"><a href="http://brazil.otservlist.org"><img src="http://img-cdn4.otservlist.org/flags/br.png" alt="brazil Otserv"/></th><th><a href="/ots/1471426">otpokemon24hs.servegame...</a></th><th>otpokemon24hs</th><th>0 (4) / 70</th><th>65.66%</th><th>66</tdh><th>x1</th><th>PVP</th><th>[ 7.1 ]</th></tr>


Chciałbym, aby wyświetliło:
wodbkopr.sytes.net
emperia-online.servegam...
thunderot.servegame.com
baiakiice2013.servegame...
otpokemon24hs.servegame...

Jakieś propozycje? smile.gif

Ten post edytował Mades 21.09.2013, 10:45:15
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
jacobson
post 21.09.2013, 10:54:32
Post #2





Grupa: Zarejestrowani
Postów: 468
Pomógł: 36
Dołączył: 14.12.2010

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


preg_match_all(|<tr.+?<th><a .+?>(.+?)</a></th>|s);

cos takiego na szybko naskrobalem powinno naprowadzic smile.gif jest na pewno lepszy sposob, ale ten powinien dzialac smile.gif
Go to the top of the page
+Quote Post
Mades
post 21.09.2013, 11:07:01
Post #3





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 3.08.2013

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


Dziękuję wink.gif
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: 14.08.2025 - 05:58