用curl 模拟登陆正方教务抓课表,可以截取出课程了,但是截取出来的课程 下午六七节  和晚上 的课程都会 与当天的不符,是前一天的课程内容。
求解释下。这得咋搞定啊小弟菜鸟!
部分代码如下:
$arr = get_td_array($table[0][0]);
   for ($d=1;$d<=7;$d++){
$shuzu[$d][1]=$arr[1][$d];
    $shuzu[$d][2]=$arr[2][$d+1];
    $shuzu[$d][3]=$arr[3][$d];
    $shuzu[$d][4]=$arr[4][$d];
    $shuzu[$d][5]=$arr[5][$d];
    $shuzu[$d][6]=$arr[6][$d];
    $shuzu[$d][7]=$arr[7][$d];
    $shuzu[$d][8]=$arr[8][$d];
    $shuzu[$d][9]=$arr[9][$d];
    $shuzu[$d][10]=$arr[10][$d];
    $shuzu[$d][11]=$arr[11][$d];
    $shuzu[$d][12]=$arr[12][$d];
    $shuzu[$d][13]=$arr[13][$d];
    $shuzu[$d][14]=$arr[14][$d];
    $shuzu[$d][15]=$arr[15][$d];
}  $xq=date('w');//取出星期几/*当星期天时 xq的值为0,需改为7*/
if($xq=='0'){
    $xq="7";
}
else
{
    //根据星期几打印课表
    if($shuzu[$xq]==null){
        //echo("你今天没有课哦!");
    }else{
            print_r($shuzu[$xq]);
        
    }
}
function get_td_array($table) {
        $table = preg_replace("'<table[^>]*?>'si","",$table);
        $table = preg_replace("'<tr[^>]*?>'si","",$table);
        $table = preg_replace("'<td[^>]*?>'si","",$table);
        $table = str_replace("</tr>","{tr}",$table);
        $table = str_replace("</td>","{td}",$table);
        //去掉 HTML 标记
        $table = preg_replace("'<[/!]*?[^<>]*?>'si","",$table);
        //去掉空白字符
        $table = preg_replace("'([rn])[s]+'","",$table);
        $table = preg_replace('/&nbsp;/',"",$table);
        $table = str_replace(" ","",$table);
        $table = str_replace(" ","",$table);
        $table = explode('{tr}', $table);
        array_pop($table);
        foreach ($table as $key=>$tr) {
                $td = explode('{td}', $tr);
                array_pop($td);
            $td_array[] = $td;
        }
        return $td_array;
}