[請益] curl抓取網頁的問題

看板PHP作者 (銘)時間16年前 (2009/08/16 12:17), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
最近在用PHP寫一個可以抓取"樂透號碼"的程式 這是要抓取的網頁 http://www.taiwanlottery.com.tw/result_all.aspx 但我一直無法抓取到全部的號碼 /_\ 以下是我寫的code <?php $url = "http://www.taiwanlottery.com.tw/result_all.aspx"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $content = curl_exec($ch); curl_close($ch); preg_match('/<td class=number>.*?([\d]+).+?<\/td>/',$content,$target); preg_match('/<td class=number_special>(.+?)<\/td>/',$content,$result); echo $target[0]; echo $result[0]; ?> 懇請大家替我解惑一下 是正規表示式寫得不好? 還是code本身需要改些什麼? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.156.76
文章代碼(AID): #1AXuXMHc (PHP)
文章代碼(AID): #1AXuXMHc (PHP)