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

看板PHP作者 (3WA問題解決專家)時間16年前 (2009/08/16 14:44), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
※ 引述《gemini392 (銘)》之銘言: : 最近在用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本身需要改些什麼? preg_match('/<td class=number>.*?([\d]+).+?<\/td>/',$content,$target); ^^ 改成 tr 你大概就看出是哪的問題了~ -- 3WA訓練家的工作室 宗旨:人生就是要爽 個人佈弱格 網址:http://3wa.tw -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.132.135.169
文章代碼(AID): #1AXwguBM (PHP)
討論串 (同標題文章)
文章代碼(AID): #1AXwguBM (PHP)