Re: [請益] curl抓取網頁的問題
※ 引述《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
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章