//活動報導網頁
$url = "http://www.tc.edu.tw/SchoolNews/show/school/id/477";
//抓取網頁內容
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
//替換掉一些鏈結
$contents=str_replace ("/upload/","http://www.tc.edu.tw/upload/",$contents);
$contents=str_replace ("/SchoolNews/","http://www.tc.edu.tw/SchoolNews/",$contents);
//取出相關內容,並儲存至陣列 match
preg_match_all('/
]*class="ui-widget-header ui-corner-top"[^>]*>(.*?)<\/h3>/si',$contents,$match[0]); preg_match_all('/
]*class="meta"[^>]*>(.*?)<\/p>/si',$contents,$match[1]); preg_match_all('/
]*class="ppy newsppy"[^>]*>(.*?) <\/span>[^.]*<\/div>[^.]*<\/div>/si',$contents,$match[2]);
preg_match_all('/
]*class="news_content"[^>]*>(.*?)<\/div>/si',$contents,$match[3]);
登入成功


