Hello smile.gif
Chcialem zapytac w jaki sposob zadawac pytania google za pomoca cURL-a? Napisalem taki skrypt (dziala on dla formularzy z method=POST mozna sie logowac itd.) jednak nie dziala on z google nie wiem do konca dlaczego (google uzywa GET). Co jest nie tak?

  1. <?php
  2. function get_website($url, $post = '', $method = '')
  3. {
  4.    $handle = curl_init($url);
  5.  
  6.    $headers = array('Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
  7.                     'Accept-Language: pl,en-us;q=0.7,en;q=0.3',
  8.                     'Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7',
  9.                     'Keep-Alive: 300',
  10.                     'Connection: keep-alive');
  11.  
  12.    curl_setopt($handle, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008070215 (Gentoo) Firefox/3.0');
  13.    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
  14.    curl_setopt($handle, CURLOPT_HEADER, 0);
  15.    curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
  16.    curl_setopt($handle, CURLOPT_ENCODING, 'gzip');
  17.    curl_setopt($handle, CURLOPT_ENCODING, 'deflate');
  18.    curl_setopt($handle, CURLOPT_COOKIEFILE, 'Skrypty/cookies.txt');
  19.    curl_setopt($handle, CURLOPT_COOKIEJAR, 'Skrypty/cookies.txt');
  20.    curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 1); // follow redirection
  21.  
  22.    if($method == 'POST')
  23.    {
  24.        curl_setopt($handle, CURLOPT_POST, 1);
  25.        curl_setopt($handle, CURLOPT_HTTPGET, 0);
  26.        curl_setopt($handle, CURLOPT_POSTFIELDS, $post);
  27.    } elseif($method == 'GET') {
  28.        curl_setopt($handle, CURLOPT_POST, 0);
  29.        curl_setopt($handle, CURLOPT_HTTPGET, 1);
  30.       curl_setopt($handle, CURLOPT_POSTFIELDS, $post);    <---- CHYBA TUTAJ JEST BLAD, ALE JAK TO ZROBIC INACZEJ?
  31.    }
  32.  
  33.    $output = curl_exec($handle);
  34.  
  35.    if(curl_errno($handle))
  36.    {
  37.        echo('Error:'.curl_errno($handle).'-> '.curl_error($handle));
  38.    } else {
  39.        echo($output);
  40.        curl_close($handle);
  41.    }
  42. }
  43. $method=GET;
  44. $post=array(&#092;"q\"=>\"onet\", \"btnG\"=>\"Szukaj w Google\");
  45. get_website(&#092;"google.pl\", $post, $method);
  46. ?>


I jeszcze jedno pytanie, co zrobic w przypadku gdzie zamiast guzika "submit" jest obrazek na ktory trzeba kliknac zeby np. sie zalogowac? Tak jak to jest na poczta.onet.pl ? Przyklad z onet-u

  1. <input document.login.ok.value=1 type=image src="_d/im/bok.gif">


Z gory dziekuje za odpowiedzi, pozdrawiam smile.gif

nie wierze, ze nikt nie wie smile.gif