Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Mała pomoc przy wyrażeniach regularnych
motyl-pl
post
Post #1





Grupa: Zarejestrowani
Postów: 294
Pomógł: 31
Dołączył: 2.04.2010

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


<a href="http://asd123.pl">http://asd123</a>
<a target="_blank" rel="nofollow" href="http://tcz.pl">http://tcz.pl</a>

  1. $tresc = file_get_contents('www');
  2. preg_match_all('/<a rel=\"nofollow\".*href=\"(.*)\".*>/iU', $tresc, $linki);
  3. print_r($linki);


Potrzebuje pobrać drugi link gdzie jest "nofollow", czy ktoś by mi mógł poprawić/pomóc poprawić moje wyrażenie regularne ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
motyl-pl
post
Post #2





Grupa: Zarejestrowani
Postów: 294
Pomógł: 31
Dołączył: 2.04.2010

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


Łatwość użycia tej biblioteki przeważa nad jej wielkością:

  1. <?php
  2. include_once('simple_html_dom.php');
  3.  
  4. $html = file_get_html('http://link z którego chcemy pobrać link nofollow');
  5.  
  6. // Find all links
  7. foreach($html->find('a') as $element) {
  8. if($element->rel == "nofollow")
  9. echo $element->href . '<br>';
  10. }
  11.  
  12. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 10.10.2025 - 15:25