PHP code example of lndj / lcrawl

1. Go to this page and download the library: Download lndj/lcrawl 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/ */

    

lndj / lcrawl example snippets




 // Require the composer autoload file
 test account!!!
$password = 'xxxxxxxx';

$user = ['stu_id' => $stu_id, 'stu_pwd' => $password];

$client = new Lcrawl('http://xuanke.lzjtu.edu.cn/', $user);

//登陆 -- 没有开启会话缓存,必须调用登陆方法。
$client->login();

//获取所有数据
$all = $client->setUa('Lcrawl Spider V2.0.2')->getAll();


// $client->getSchedule();
// $client->getCet();



//实例化过程中传入第三个值
$client = new Lcrawl('http://xuanke.lzjtu.edu.cn/', $user, true);

$all = $client->setUa('Lcrawl Spider V2.0.2')->setTimeOut(3.0)->getAll();

//实例化过程中传入第三个值
$client = new Lcrawl('http://xuanke.lzjtu.edu.cn/', $user, true);


use Doctrine\Common\Cache\RedisCache;

$cacheDriver = new RedisCache();

// 创建 redis 实例
$redis = new Redis();
$redis->connect('redis_host', 6379);

$cacheDriver->setRedis($redis);

//设置使用redis来缓存会话
$client->setCache($cacheDriver);



$loginParam = [
    'viewstate' => '__VIEWSTATE', //隐藏域字段名称
    'stu_id' => 'TextBox1', //学号字段名称
    'passwod' => 'TextBox2', //密码字段
    'role' => 'RadioButtonList1', //角色
    'button' => 'Button1' //按钮
];

$client = new Lcrawl('http://xuanke.lzjtu.edu.cn/', $user, true, $loginParam);

//other code...


use Doctrine\Common\Cache\PredisCache;

$predis = app('redis')->connection();// connection($name), $name 默认为 `default`
$cacheDriver = new PredisCache($predis);

//设置使用redis来缓存会话
$client->setCache($cacheDriver);