Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php][curl] Problem z kopiowaniem źródła
wht84
post
Post #1





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 10.12.2007
Skąd: WWA YelonkY

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


Curl zamiast kopiować mi źródło strony wyrzuca

Found
The document has moved here.

Może ktoś wie co się dzieje
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 6)
webdice
post
Post #2


Developer


Grupa: Moderatorzy
Postów: 3 045
Pomógł: 290
Dołączył: 20.01.2007




Podaj kod.
Go to the top of the page
+Quote Post
wht84
post
Post #3





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 10.12.2007
Skąd: WWA YelonkY

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


  1. <?php
  2. ini_set('error_reporting', E_ALL ^ E_NOTICE);
  3. ini_set('display_errors',1);
  4.  
  5. header('Content-type: text/html; charset=iso-8859-2');
  6.  
  7.  
  8. $fp = fopen('c:wwwdata.csv', 'a');
  9. fwrite($fp, "");
  10. $temp = fopen('c:www\temp.txt', "w+");
  11.  
  12. fputcsv($fp, $fheaderData, ';', "\""); 
  13. $count = 0;
  14.  
  15.  
  16. function findinside($start, $end, $string) {
  17. preg_match_all('/' . preg_quote($start, '/') . '(.*)'. preg_quote($end, '/').'/i', $string, $m);
  18. return $m[1];
  19. }
  20.  
  21.  
  22.  
  23. for($page_id = 0; $page_id<=100; $page_id++)
  24. {
  25. $url = "http://www.jakasstrona/index.jsp?nr_strony".$page_id;
  26.  
  27. $c = curl_init();
  28. curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; pl; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3');
  29. curl_setopt($c, CURL_BODY, 0);
  30. curl_setopt($c, CURLOPT_URL, $url);
  31. curl_setopt($c, CURL_RETURNTRANSFER, 0);
  32. curl_setopt($c, CURLOPT_FILE, $temp);
  33.  curl_exec($c);
  34. curl_close($c);
  35.  
  36. $allTXT = file_get_contents("temp.txt");
  37. echo $allTXT;
  38.  
  39.  
  40. $out_full_name = findinside("cos","cos",$allTXT);
  41.  
  42. var_dump($out_full_name);
  43. $i_c = count ($out_full_name);
  44. for($i=0; $i<$i_c; $i++){
  45.  
  46. $count++;
  47.  
  48.  
  49.  
  50. $list = array($count, $out_full_name[$i]);
  51. fputcsv($fp, $list, ';', "\"");
  52.  
  53. echo "<table><tr><td>".$out_full_name[$i]."</td></tr>";  
  54. } 
  55. echo "</table>";
  56.  
  57. }
  58.  
  59.  
  60.  
  61. ?>
Go to the top of the page
+Quote Post
webdice
post
Post #4


Developer


Grupa: Moderatorzy
Postów: 3 045
Pomógł: 290
Dołączył: 20.01.2007




Najprawdopodobniej dlatego że podajesz niepoprawny adres strony.
Go to the top of the page
+Quote Post
wht84
post
Post #5





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 10.12.2007
Skąd: WWA YelonkY

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


Adres jest poprawny, jak go kopiuje i wklejam w przeglądarce wszystko jest OK.
Go to the top of the page
+Quote Post
webdice
post
Post #6


Developer


Grupa: Moderatorzy
Postów: 3 045
Pomógł: 290
Dołączył: 20.01.2007




To podaj ten adres.
Go to the top of the page
+Quote Post
Kicok
post
Post #7





Grupa: Zarejestrowani
Postów: 1 033
Pomógł: 125
Dołączył: 17.09.2005
Skąd: Żywiec

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


Najprawdopodobniej strona została przeniesiona i serwer wysyła nagłówek "Location: nowastrona.jsp" i trochę tekstu. Przeglądarka podąża za przekierowaniem, a cURL nie.

Po pierwsze spróbuj użyć flagi CURLOPT_FOLLOWLOCATION.
Jak nie pomoże to użyj CURLOPT_HEADER i spróbuj wyciągnąć z nagłówków lub linku nowy adres forum i wywołać go nowym curl_init()


--------------------
"Sumienie mam czyste, bo nieużywane."
Go to the top of the page
+Quote Post

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: 20.08.2025 - 06:59