Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Sczytywanie danych z googla
pawelk3k
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 8.05.2012

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


Witam,
Robię właśnie program który sczytuje pierwszą stronę z googla (tuż po wpisaniu interesującego nas hasła). Kod wygląda tak:

  1. <?php
  2. $fraza="komputer";
  3. $url="http://www.google.pl/search?hl=pl&q=$fraza&btnG=Szukaj+w+Google&lr=";
  4. $tekst = file_get_contents($url);
  5. preg_match_all('@<h3 class=r><a href="(.*)" class=l>(.*)</a></h3>(.*)<div class="s">(.*)<br><cite>@iU', $tekst, $wynik);
  6. print_r($wynik);
  7. ?>

(Program zaczerpnięty z http://peb.pl/tworzenie-stron/353712-curl-na-google-2.html).


To co program wyświetla to :

Array ( [0] => Array ( ) [1] => Array ( ) [2] => Array ( ) [3] => Array ( ) [4] => Array ( ) )

Podejrzewam ze błąd jest gdzieś w funkcji preg_match_all. Zależy mi tylko na linku z strony. Lecz niestety nie wiem gdzie (IMG:style_emoticons/default/sad.gif) proszę o pomoc.
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: 2.10.2025 - 23:00