我使用curl來刮掉一個HTML頁面。它完美地剔除了前置標籤之間的數據。不過,我想跳過前五行。有什麼我可以添加到代碼來做到這一點?這裏是我的代碼:php curl代碼跳過被刮掉的行
<?php
function curl_download($Url){
if (!function_exists('curl_init')){
die('cURL is not installed. Install and try again.');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$start = strpos($output, '<pre>');
$end = strpos($output, '</pre>', $start);
$length = $end-$start;
$output = substr($output, $start, $length);
curl_close($ch);
return $output;
}
print curl_download('http://athleticsnews.co.za/results/20140207BOLALeague3/140207F006.htm');
?>
這是HTML的樣子,可推動在拉:
<pre>
AllTrax Timing - Contractor License 4/22/2014 - 8:31 AM
Boland Athletics League 3 - 2/7/2014
Hosted by Maties AC
Coetzenburg, Stellenbosch
Event 6 Girls 14-15 200 Meter Sprint
所以我試圖排除前四行加上空行,並開始從刮與事件6啓動線...
你能不能應用正則表達式的捲曲輸出? – Drakes
你可以使用爆炸打破$輸出,並得到你想要的部分 – Babar
哪五行你沒有得到? – Thamaraiselvam