Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][cURL]preg_match_all i google
NeRoK
post
Post #1





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 29.04.2006

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


Witam,

Mam taki kod:
  1. <?php
  2. $ch = curl_init();
  3. curl_setopt($ch, CURLOPT_HEADER, false);
  4. curl_setopt($ch, CURLOPT_HTTPGET, true);
  5. curl_setopt($ch, CURLOPT_POST, false);
  6. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  7.  
  8. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1");
  9. $strona = curl_exec($ch);
  10. curl_close($ch);
  11.  
  12. preg_match_all('@<h3 class=r><a href="(.*)" class=l>(.*)</a></h3>(.*)<div class="s">(.*)<br><cite>@iU', $strona, $wynik);
  13. print_r($wynik);
  14. ?>


Niestety w tablicy nie mam żadnych wyników... Podejrzewam, że "coś jest źle" z wyrażeniem regularnym. Jak mogę poprawić to wyrażenie, żeby działało jak należy?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
NeRoK
post
Post #2





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 29.04.2006

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


  1. <?php
  2. $url = 'http://www.google.pl/search?hl=pl&chs=wui&q='.urlencode($zapytanie);
  3.    
  4.    
  5.    #CURL START
  6.    $ch = curl_init();
  7.    curl_setopt($ch, CURLOPT_HEADER, false);
  8.    curl_setopt($ch, CURLOPT_HTTPGET, true);
  9.    curl_setopt($ch, CURLOPT_POST, false);
  10.    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  11.    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1");
  12.    $strona = curl_exec($ch);
  13.    curl_close($ch);
  14.    echo $strona;
  15.    #CURL END
  16.    preg_match_all('/<h3 class=r><a href="(.*?)" class=l(?:.*?)>(.*?)</a></h3>(.*?)<div class="s">(.*?)<br><cite>/is', $strona, $wynik);
  17.    print_r($wynik);
  18. ?>


$zapytanie = $_REQUEST['zapytanie']; z pliku szukaj.php

Ten post edytował NeRoK 4.02.2009, 16:55:29
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: 8.10.2025 - 21:23