Re: [請益] 抓取網頁資料

看板PHP作者 (小毛)時間19年前 (2006/05/30 15:54), 編輯推噓4(400)
留言4則, 3人參與, 最新討論串6/8 (看更多)
<? $urlTemplate = "http://210.69.47.19/phnsweb/HCHL1_Servlet?action=detail&" ."President_no=0615###id###&System_code=BUSS"; for ($i=6991;$i<=7991;$i++){ $urlString = str_replace("###id###", $i, $urlTemplate); $contentString = implode("", file($urlString)); $fi = fopen( "0615".$i.".htm", "w");//假設抓回來之後要存起來 fwrite($fi, $contentString); fclose($fi); sleep(10);//不要fetch檔案太密集,要有禮貌 }//end for ?> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 192.192.154.45

06/01 09:05, , 1F
要有禮貌 :)
06/01 09:05, 1F

06/01 23:43, , 2F
^^ thx!
06/01 23:43, 2F

09/02 02:54, , 3F
thx
09/02 02:54, 3F

09/05 03:40, , 4F
備註: 有些網頁讀取太頻繁的話 會被當成robot而不送資料給你
09/05 03:40, 4F
文章代碼(AID): #14U_e-MP (PHP)
文章代碼(AID): #14U_e-MP (PHP)