Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] curl pobraniu paru stron
icetab
post
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
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
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 ? (IMG:style_emoticons/default/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
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
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ć (IMG:style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post

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: 28.09.2025 - 03:35