Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Wyciąganie informacji z strony
Mati010
post
Post #1





Grupa: Zarejestrowani
Postów: 27
Pomógł: 0
Dołączył: 2.02.2009
Skąd: gliwice

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


Witajcie, mam zrobiony skrypt logowania prze CURL, i takie pytanie bo nie mam pomysłu jak zrobić, aby pobrać dane z kodu strony po zalogowaniu (IMG:style_emoticons/default/questionmark.gif)

Kod logowania:
  1. $f['ips_username'] = 'Login';
  2. $f['ips_password'] = 'haslo';
  3. $f['rememberMe'] = '1';
  4. $f['anonymous'] = '1';
  5. $f['referer'] = 'http://stronka/index.php?';
  6. $f['auth_key'] = '880ea6a14ea49e853634fbdc5015a024';
  7. $f['input_submit'] = 'Zaloguj';
  8.  
  9. $ch = curl_init();
  10. curl_setopt($ch, CURL_TIMEOUT, 120);
  11. curl_setopt($ch, CURL_RETURNTRANSFER, 0);
  12. curl_setopt($ch, CURLOPT_URL, "http://stronka/index.php?app=core&module=global&section=login&do=process");
  13. curl_setopt($ch, CURL_POST, 1);
  14. curl_setopt($ch, CURLOPT_POSTFIELDS, $f);
  15. curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1 );
  16. curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/cookies.txt');
  17. curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookies.txt');
  18. curl_exec($ch);
  19. curl_close($ch);
  20.  


Chciałbym, żeby skrypt pobrał i wyświetlił:

  1. <input type='hidden' name='kodzidopobrania' value='qwerty' />
  2. <input type='hidden' name='kodzidopobrania2' value='qwerty123' />


Prosiłbym o pomoc z góry dzięki.


Dałem radę w połowie z tym mianowicie

  1. $host = "http://stronka/index.php?";
  2.  
  3. $curl = curl_init($host);
  4. curl_setopt($curl, CURLOPT_HEADER, 0);
  5. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  6.  
  7. $wynik = curl_exec($curl);
  8.  
  9.  
  10.  
  11.  
  12. preg_match('#<a href="http://www.tserwery.pl/" title="Tserwery.pl - hosting gier">(.*)</a> #', $wynik, $podaj);
  13.  
  14. print_r($podaj[1]);
  15.  
  16. curl_close($curl);


Pokazuje to co chce czyli: Tserwery.pl
Lecz gdy próbuję zrobić tak:

  1. $host = "http://stronka/index.php?";
  2.  
  3. $curl = curl_init($host);
  4. curl_setopt($curl, CURLOPT_HEADER, 0);
  5. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  6.  
  7. $wynik = curl_exec($curl);
  8.  
  9.  
  10.  
  11. preg_match("#<input type='hidden' name='kodzidopobrania2' value='(.*)' /> #", $wynik, $podaj);
  12.  
  13. print_r($podaj[1]);
  14.  
  15. curl_close($curl);

To już nie wyświetla nic.

Ten post edytował Mati010 6.01.2013, 16:34:20
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: 3.10.2025 - 16:47