Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Pobieranie danych poprzez wykorzystanie PROXY?, nie curl'em ..
ciniutek
post
Post #1





Grupa: Zarejestrowani
Postów: 31
Pomógł: 0
Dołączył: 29.05.2011

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


Witam . Czy jest możliwość pobierania danych za pośrednictwem file_get_contents poprzez proxy ? Tylko nie chodzi mi o curl'a ..

  1.  
  2. <?
  3. $page = file_get_contents("http://strona");
  4. $wzor = '~<li><a title="(.*)" href="(.*)" >(.*)</a><br />~';
  5.  
  6. preg_match_all($wzor, $page, $matches);
  7. print_r($matches);
  8. ?>



Ogarnąłem coś takiego , ale nie działa (IMG:style_emoticons/default/sad.gif)

  1. <?
  2.  
  3. function pobierz_proxy($adres, $proxy, $port){
  4. $fp = fsockopen($proxy, $port) or die("Zapraszamy za chwile.");
  5. fputs($fp, "GET $adres HTTP/1.1\r\nHost: $proxy\r\n\r\n");
  6. while(!feof($fp)){
  7. $line = fgets($fp, 4000);
  8. $pobierz .= $line;
  9. }
  10. fclose($fp);
  11. return $pobierz;
  12. }
  13.  
  14.  
  15. $proxy="118.97.48.185";
  16. $port="80";
  17.  
  18.  
  19. $sData=pobierz_proxy($adres, $proxy, $port);
  20.  
  21.  
  22.  
  23. $adres = file_get_contents("http://strona");
  24.  
  25. $wzor = '~<li><a title="(.*)" href="(.*)" >(.*)</a><br />~';
  26.  
  27. preg_match_all($wzor, $sData, $matches);
  28. print_r($matches);
  29.  
  30.  
  31. ?>


Ten post edytował ciniutek 23.06.2011, 23:09:42
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
ciniutek
post
Post #2





Grupa: Zarejestrowani
Postów: 31
Pomógł: 0
Dołączył: 29.05.2011

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


A teraz , jak chce połączyć curl'a z file_get_contents ?

  1. <?
  2.  
  3. $ch_e=curl_init('http://strona');
  4. curl_setopt($ch_e, CURLOPT_HEADER, 0);
  5. curl_setopt($ch_e, CURLOPT_RETURNTRANSFER, 1);
  6. curl_setopt ($ch_e, CURLOPT_PROXY, 'http://203.187.186.142:80');
  7. curl_setopt($ch_e, CURLOPT_HTTPPROXYTUNNEL, FALSE);
  8. curl_setopt($ch_e, CURLOPT_CONNECTTIMEOUT, 25);
  9. $strona_e=curl_exec($ch_e);
  10. echo $strona_e.' ok';
  11. echo ('<br><br><br>');
  12.  
  13.  
  14. $adres = file_get_contents $strona_e;
  15. $wzor = '~<li><a title="(.*)" href="(.*)" >(.*)</a><br />~';
  16.  
  17. preg_match_all($wzor, $adres, $matches);
  18. print_r($matches);
  19.  
  20.  
  21. ?>


Wyskakuje błąd . Co jest nie tak ? (IMG:style_emoticons/default/sad.gif)
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 Aktualny czas: 10.10.2025 - 23:26