PHP code example of leoleoasd / zf_spider

1. Go to this page and download the library: Download leoleoasd/zf_spider library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

leoleoasd / zf_spider example snippets



 GuzzleHttp\Client as HttpClient;

$client = new \ZfSpider\Client(['stu_id' => 'xxx', 'stu_pwd' => 'xxx']);

var_dump($client->login_vpn('xxx',"xxx"));
var_dump(serialize($client->getCookieJar()));
//$client->setCookieJar(unserialize(""));
$client->login();

var_dump($client->getExams());
var_dump($client->getExams('2019-2020','1'));
var_dump($client->getGrade());
var_dump($client->getSchedule());
var_dump($client->getSchedule('2019-2020','1'));


$client->login_vpn("学号", "密码");
// 返回$this, 可链式调用.

if($client->test_vpn()){
    foo();
}
// 返回一个Bool, 代表当前是否已经登录了vpn.

$client->login();
// 登录教务系统.

$client->login_vpn("xxx","xxx");
$jar = $client->getCookieJar();


$jar = unserialize("");
$client->setCookieJar($jar);
// 设置cookieJar和获取cookieJar. 可登录vpn后缓存.


$client->getGrade();
// 获取所有已修课程成绩.
/*
[
    {
        "year":"2019-2020",
        "term":"1",
        "courseId":"0006794",
        "courseName":"大学生心理适应指导",
        "courseType":"校选修课",
        "courseBelong":"第二课堂",
        "courseCredit":"1.0",
        "gradePoint":"4.00",
        "score":"100",
        "minorMark":"0", // 辅修标记
        "makeUpScore":" ", // 补考成绩
        "retakeMark":"0", // 重修标记
        "retakeScore":" ", // 重修成绩
        "academy":"学生发展指导中心",
        "remark":" "
    },
    ...
]
*/

// 获取考试信息.
var_dump($client->getExams());
var_dump($client->getExams('2019-2020','1'));
/*
[
    {
        "courseId":"(2019-2020-1)-0004312-08625-3",
        "courseName":"中国近现代史纲要",
        "name":"xxx",
        "dateTime":"xxx",
        "classroom":"xxx",
        "type":" ",
        "seat":"xxx",
        "campus":"通州校区"
    },
    ...
]
 */

// 获取课表信息
var_dump($client->getSchedule());
var_dump($client->getSchedule('2019-2020','1'));