Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]cURL
red9skull
post 9.02.2010, 21:59:51
Post #1





Grupa: Zarejestrowani
Postów: 157
Pomógł: 0
Dołączył: 11.07.2009
Skąd: root

Ostrzeżenie: (10%)
X----


Mój kod i wygląda on mniej więcej tak:
  1. <?php
  2.  
  3.  
  4. class madafaka
  5. {
  6. var $delay; // Czas miedzy wejściami w sekundach
  7.  
  8. var $timeout; // timeout dla curla
  9.  
  10. var $cookie_file; // nazwa pliku cookie
  11.  
  12. var $type_url; // Nie zmieniac !!
  13. // Jest puste i będzie puste
  14.  
  15.  
  16. private function curl_get( $url )
  17. {
  18. $conn = curl_init();
  19. curl_setopt( $conn, CURLOPT_URL, $url );
  20. curl_setopt( $conn, CURLOPT_TIMEOUT, $this->timeout );
  21. if( $this->proxy )
  22. {
  23. curl_setopt( $conn, CURLOPT_PROXY, $this->proxy );
  24. }
  25. curl_setopt( $conn, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; U; pl; rv:1.8.1) Gecko/20061208 Firefox/3.5.4' );
  26. curl_setopt( $conn, CURLOPT_COOKIEJAR, $this->cookie_file );
  27. curl_setopt( $conn, CURLOPT_COOKIEFILE, $this->cookie_file );
  28. curl_setopt( $conn, CURLOPT_ENCODING, 'gzip, deflate' );
  29. curl_setopt( $conn, CURLOPT_RETURNTRANSFER, 1 );
  30. curl_setopt( $conn, CURLOPT_REFERER, 'http://www.google.pl/' );
  31.  
  32. $data = curl_exec( $conn );
  33. curl_close( $conn );
  34. return $data;
  35. }
  36.  
  37. function assassin()
  38. {
  39. for( $x = 0; $x < 1; $x++ )
  40. {
  41. /*------------------- :] -------------------*/
  42. $data = $this->curl_get( 'http://www.google.pl' );
  43. echo "Roger that!\n";
  44. var_dump($data);
  45. /*------------------- :] -------------------*/
  46. if( $this->delay != 0 )
  47. {
  48. sleep( $this->delay );
  49. }
  50. }
  51. }
  52. }
  53.  
  54. $assassin = new madafaka();
  55.  
  56. $assassin->delay = 2; // Czas miedzy wejściami w sekundach
  57.  
  58. $assassin->timeout = 5; // timeout dla curla
  59.  
  60. $assassin->cookie_file = 'assassin.txt'; // nazwa pliku cookie
  61.  
  62. $assassin->assassin(); // :]
  63.  
  64.  
  65.  
  66. ?>


I wczoraj działał biggrin.gif A dzisiaj nie chce ruszyć. var_dump($data); zwraca FALSE. Czy wam śmiga?

Powiedzcie mi tylko, czy wam działa ten kod.

Ten post edytował red9skull 9.02.2010, 22:00:17


--------------------
zmoderowano - zbyt fajna
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 08:07