Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] curl pobraniu paru stron
icetab
post 2.11.2010, 19:02:56
Post #1





Grupa: Zarejestrowani
Postów: 226
Pomógł: 3
Dołączył: 3.04.2007

Ostrzeżenie: (50%)
XXX--


Jak pobrać kilka stron na raz w jednym skrypcie curl strony by mialy adresy index.php?id=0, index.php?id=15,index.php?id=30,index.php?id=45 itd ?
Go to the top of the page
+Quote Post
flashdev
post 2.11.2010, 19:21:39
Post #2





Grupa: Zarejestrowani
Postów: 812
Pomógł: 117
Dołączył: 2.12.2008

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


Zrobić to samo co w przypadku pobrania jednej strony tylko kilka razy.

  1. for( $i = 0; $i < $n; $i++ ){
  2. pobierz_raz('index.php?id=' . $i );
  3. }


--------------------
Go to the top of the page
+Quote Post
icetab
post 2.11.2010, 19:30:34
Post #3





Grupa: Zarejestrowani
Postów: 226
Pomógł: 3
Dołączył: 3.04.2007

Ostrzeżenie: (50%)
XXX--


Zrobiłem tak jak napisałeś ale nie działa w czym problem ? smile.gif

  1. for( $i = 0; $i < $n; $i++ ){
  2. $curl2 = curl_init('http://forumlink.pl/forum/viewtopic.php?t=105&postdays=0&postorder=asc&start='.$i.'');
  3.  
  4. curl_setopt($curl2, CURLOPT_HEADER, 0);
  5. curl_setopt($curl2, CURLOPT_RETURNTRANSFER, true);
  6. curl_setopt($curl2, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12");
  7. curl_setopt($curl2, CURLOPT_COOKIEFILE, "cookie.txt");
  8. curl_setopt($curl2, CURLOPT_COOKIEJAR, "cookie.txt");
  9. $strona = curl_exec($curl2);
  10. echo $strona;
  11. curl_close($curl2);
  12. }
Go to the top of the page
+Quote Post
flashdev
post 2.11.2010, 19:33:20
Post #4





Grupa: Zarejestrowani
Postów: 812
Pomógł: 117
Dołączył: 2.12.2008

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


Dopisz na początek ile stron chciałbyś pobrać.
  1. // np.
  2. $n = 15;


--------------------
Go to the top of the page
+Quote Post
icetab
post 3.11.2010, 16:03:20
Post #5





Grupa: Zarejestrowani
Postów: 226
Pomógł: 3
Dołączył: 3.04.2007

Ostrzeżenie: (50%)
XXX--


działa ale strasznie nie stabilnie bo biorę max 3 strony i skrypt zawiesza się, idzie to jakoś zoptymalizować questionmark.gif
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 Wersja Lo-Fi Aktualny czas: 15.07.2025 - 14:44