### Implement a standard LoadTask Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d Example of overriding the start method to execute a spider and return a list of live data. ```java @Override public List start(){ List lives; Spider spider = SpiderFactory.buildSpider(ConstPool.PLATFORM.DOUYU.getName(), //平台名称 douyuHotLiveProcessor, //processor loadConfig.getUrl()); //url try { lives = getData(spider,loadConfig.getUrl()); }catch (Exception e){ fail(e); return null; } success(); return lives; } ``` -------------------------------- ### Create a GuardPlugin Source: https://geniusay.github.io/ChopperBot-Doc/pages/c30e11 GuardPlugin runs in a dedicated thread pool. The start method automatically loops, and lifecycle methods should call their super equivalents. ```java start(){ print() } 同等于 while{ print() } ``` ```java public class GeniusGuardPlugin extends GuardPlugin { public GeniusGuardPlugin(String module, String pluginName, List needPlugins, boolean isAutoStart) { super(module, pluginName, needPlugins, isAutoStart); //afterDo = true; 初始化后运行 } //初始化操作。重写时请使用父类的init @Override public boolean init() { super.init(); //代码 } //运行方法,ChopperBotGuardPool将会不断运行这个方法 @Override public void start(){ } //关闭操作,请使用父类的shutdown,或者自行进行isStop的更改 @Override public void shutdown() { super.shutdown(); //代码 } //初始化后操作,请使用父类afterInit() @Override public void afterInit() { super.afterInit(); //代码 } } ``` -------------------------------- ### JSON Data Structure Example Source: https://geniusay.github.io/ChopperBot-Doc/pages/779a6c Example JSON structure used for file caching operations. ```json { "updateTime": "2023-05-06 04:05:20", "data": { "account": { "src": "./config/account", "list": [1,2,3,4,5] } } } ``` -------------------------------- ### Retrieve Cached Data Source: https://geniusay.github.io/ChopperBot-Doc/pages/779a6c Use the get method with variable arguments to perform nested lookups in the cached JSON structure. ```java fileCache.get("account","src"); fileCache.get("account","list","2"); ``` -------------------------------- ### Initialize FileCache Source: https://geniusay.github.io/ChopperBot-Doc/pages/779a6c Create a FileCache instance by wrapping a ConfigFile object. ```java ModuleSrcConfigFile chopperBotConfigFile = new ModuleSrcConfigFile(); FileCache fileCache = new FileCache(chopperBotConfigFile); ``` -------------------------------- ### 创建 CommonInitMachine 启动器 Source: https://geniusay.github.io/ChopperBot-Doc/pages/c30e11 适用于 CommonPlugin、GuardPlugin 和 ConfigFile 插件。需继承 CommonInitMachine 并使用 @Plugin 注解。 ```java @Plugin(moduleName = 所属模块名, pluginName = 插件名称, pluginName_CN = 插件中文名(不必要), pluginDescription = 插件描述(不必要), needPlugin = {所依赖的插件}, pluginClass= 要初始化的插件类 ) public class HotGuardInitMachine extends CommonInitMachine { public HotGuardInitMachine(List needPlugins, boolean isAutoStart, String moduleName, String name, Class clazz) { super(needPlugins, isAutoStart, moduleName, name, clazz); } } ``` -------------------------------- ### 访问 InitPluginRegister 全局注册表 Source: https://geniusay.github.io/ChopperBot-Doc/pages/c30e11 通过 InitPluginRegister 类获取插件信息、检查注册状态或手动注册插件。 ```java //获得全部插件 InitPluginRegister.allPlugin; //获取某模块下所有插件 InitPluginRegister.modulePlugin.get(模块名); //获取某插件的所有子插件 InitPluginRegister.fatherAndSonPlugin.get(插件名); //获得某插件自身模块下的所有子插件 InitPluginRegister.moduleFatherAndSonPlugin.get(插件名); //判断插件是否注册 InitPluginRegister.isRegister(插件名); //获取正在运行的插件 InitPluginRegister.getPlugin插件名); //注册插件 InitPluginRegister.register(CommonInitMachine); ``` -------------------------------- ### Create a Module InitMachine Source: https://geniusay.github.io/ChopperBot-Doc/pages/c30e11 Modules must extend ModuleInitMachine and provide a no-argument constructor that defines dependencies, logger, and module name. ```java public class GeniusModuleInitMachine extends ModuleInitMachine { //这里要是无参构造函数 public GeniusModuleInitMachine() { super( List.of(ConstPool.FILE), // 依赖的模块名称 ChopperLogFactory.getLogger("Genius"), // 依赖的模块日志名称 "Genius" // 模块名称 ); } } ``` -------------------------------- ### Implement Global FileCache Source: https://geniusay.github.io/ChopperBot-Doc/pages/779a6c Define a global configuration class to initialize and register FileCache instances for system-wide monitoring. ```java public class GlobalFileCache { public static FileCache ModuleSrcConfigFile; //写入你的FileCache static { try { //在此初始化 ModuleSrcConfigFile = new FileCache(new ModuleSrcConfigFile()); } catch (FileCacheException e) { throw new RuntimeException(e); } } //再此添加到文件监控管理队列中 public static List fileCaches = List.of(ModuleSrcConfigFile); } ``` -------------------------------- ### Register InitMachine in InitWorld Source: https://geniusay.github.io/ChopperBot-Doc/pages/e3a691 Add initialized components to the InitWorld instance to execute the startup sequence. ```java public static boolean Init(){ return InitWorld.getInstance() .setInitMachines( List.of( new ModuleSrcConfigFileInit(), new FileCacheManagerInit() ) ).start(); } ``` -------------------------------- ### 使用 PluginCheckAndDo 进行条件操作 Source: https://geniusay.github.io/ChopperBot-Doc/pages/c30e11 根据插件是否存在执行不同的逻辑或获取返回值。 ```java PluginCheckAndDo.CheckAndDo( (plugin)->{ //存在时执行的方法 }, ()->{ //不存在时执行的方法 }, pluginName ); ``` ```java PluginCheckAndDo.CheckAndGet( (plugin)->{ //存在时执行的方法 return new User(); }, pluginName,User.class ); ``` -------------------------------- ### Implement a custom ConfigFile Source: https://geniusay.github.io/ChopperBot-Doc/pages/e3a691 Extend the ConfigFile class and call super() in the constructor to define file path, name, data structure, and type. ```java public class HelloConfigFile extends ConfigFile { public ModuleSrcConfigFile() { super("./config/" , "helloConfig.json" , new HashMap(), FileType.CHOPPER_BOT); } } ``` -------------------------------- ### Implement a LoadConfig builder Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d Create a builder class to automate the construction of LoadConfig objects for plugins. ```java @Component public class BiliBiliLiveLoadConfigBuilder extends CommonLoadConfigBuilder { @Override public BilibiliLiveOnlineConfig build(Object obj) { if(obj instanceof BiliBiliLive){ String liveId = ((BiliBiliLive) obj).getLiveId(); String liver = ((BiliBiliLive) obj).getLiver(); String showTime = ((BiliBiliLive) obj).getShowTime(); String path = LiveModuleConstPool.getPlatformLiveSavePath(ConstPool.PLATFORM.BILIBILI); BilibiliLiveOnlineConfig bilibiliLiveOnlineConfig = new BilibiliLiveOnlineConfig(liveId, path, LoadLiveConfig.fileName(liveId, liver,showTime), true); bilibiliLiveOnlineConfig.setShowDownloadTable(true); bilibiliLiveOnlineConfig.setLiverName(liver); bilibiliLiveOnlineConfig.setRoomName(((BiliBiliLive) obj).getLiveName()); bilibiliLiveOnlineConfig.setStartTime(showTime); return bilibiliLiveOnlineConfig; } return null; } } ``` -------------------------------- ### LoadConfig常用参数字段 Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d 列出了LoadConfig中可用的基础爬虫参数,包括请求头和Cookie信息。 ```java String url; String startTime; String UserAgent; String Origin; String Referer; Map header; //头信息 Map cookie; //Cookie ``` -------------------------------- ### Write and read JSON files using JsonFileUtil Source: https://geniusay.github.io/ChopperBot-Doc/pages/779a6e Shows how to serialize objects to JSON files and deserialize them back into Java objects or collections. ```java public void writeClassInJsonFile() { Student student = new Student( "Genius", 18, "HUST", "CS", List.of("Coding", "Reading", "Playing"), Map.of("QQ", "123456789", "WeChat", "987654321") ); JsonFileUtil.writeJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\", "student.json", student); JsonFileUtil.writeBigJsonFile("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json", List.of(student)); JsonFileUtil.writeJsonFileIsExist("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student3.json", student); System.out.println(JsonFileUtil.readJsonFileToObject("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student.json", Student.class)); System.out.println(JsonFileUtil.readJsonFileToObject("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\student2.json",List.class)); } ``` -------------------------------- ### Implement InitMachine interface Source: https://geniusay.github.io/ChopperBot-Doc/pages/e3a691 Create a class that implements the InitMachine interface to define custom initialization logic. ```java public class FileCacheManagerInit implements InitMachine{ @Override public boolean init() { FileCacheManagerInstance.getInstance().start(); return true; } } ``` -------------------------------- ### Delete a directory using FileUtil Source: https://geniusay.github.io/ChopperBot-Doc/pages/779a6e Demonstrates how to remove a directory and its contents using the FileUtil utility class. ```java public void testDelete() throws IOException { FileUtil.deleteDirectory("E:\\Project\\ChopperBot\\FileModule\\src\\main\\resources\\trash"); } ``` -------------------------------- ### Create a ConfigFile Plugin Source: https://geniusay.github.io/ChopperBot-Doc/pages/c30e11 ConfigFile plugins manage data files automatically via FileCacheManager. ```java public class GeniusConfigFile extends ConfigFile<数据类型> { public GeniusConfigFile(String module, String pluginName, List needPlugins, boolean isAutoStart) { super(module,pluginName,needPlugins,isAutoStart ,filePath, fileName,//文件路径 文件名 Map.of("taskCenter",new TaskCenterConfig(10,50,1000)), //文件内容 FileType.CREEPER); //文件类型 } } ``` -------------------------------- ### 实现爬虫任务类LoadTask Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d 通过继承CommonLoadTask实现具体的爬虫逻辑,核心在于start方法中执行数据抓取。 ```java /** * 网上随便找的个爬豆瓣的demo,需要导入jsoup,不清楚能不能运行 * 链接:https://www.w3cschool.cn/article/69979497.html */ public class DouBanLoadTask extends CommonLoadTask> { public DouBanLoadTask(DouyuBanLoadConfig loadConfig) { super(loadConfig); } @Override public ArrayList start() { try { // 连接到URL,并获取网页的文档对象 Document doc = Jsoup.connect(loadConfig.getUrl()).get(); // 选择所有包含书籍信息的元素 Elements elements = doc.select("div.article > div.indent > table"); // 遍历每个元素 for (Element element : elements) { // 提取书籍的标题 String title = element.select("div.pl2 > a").attr("title"); // 提取书籍的作者 String author = element.select("p.pl").text().split("/")[0]; // 提取书籍的评分 String rating = element.select("span.rating_nums").text(); // 提取书籍的简介 String summary = element.select("span.inq").text(); // 创建一个Book对象 Book book = new Book(title, author, rating, summary); // 将Book对象添加到列表中 books.add(book); } } catch (IOException e) { e.printStackTrace(); } return books; } @Override public void end() { } class Book{ private String title; // 标题 private String author; // 作者 private String rating; // 评分 private String summary; // 简介 // 书籍的构造方法 public Book(String title, String author, String rating, String summary) { this.title = title; this.author = author; this.rating = rating; this.summary = summary; } } } ``` -------------------------------- ### Create a CommonPlugin Source: https://geniusay.github.io/ChopperBot-Doc/pages/c30e11 CommonPlugin requires a specific constructor signature and provides lifecycle methods like init, shutdown, and afterInit. ```java public class GeniusPlugin extends CommonPlugin { //重写构造方法 且参数顺序不能变 public GeniusPlugin(String module, String pluginName, List needPlugins, boolean isAutoStart) { super(module, pluginName, needPlugins, isAutoStart); } //初始化操作 @Override public boolean init() { } //关闭操作 @Override public void shutdown() { } //初始化后的操作 @Override public void afterInit() { } } ``` -------------------------------- ### Implement a WebSocketLoadTask Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d Template for creating a WebSocket-based crawler by extending WebSocketLoadTask and overriding lifecycle methods. ```java public class HelloLoadTask extends WebSocketLoadTask { public DouyuLiveBarrageLoadTask(HelloLoadConfig loadConfig) throws FileCacheException { super(loadConfig); } @Override public void preHandler(){ // try { // client.closeBlocking(); // }catch (InterruptedException e){ // // } } @Override public String handler() { return "hello world"; } @Override public void onOpen(ServerHandshake serverHandshake) { //client.send("hello"); } @Override public void onMessage(String s) {} @Override public void onMessage(ByteBuffer buffer) {} @Override public void onClose(int i, String s, boolean b) { //client.close() } @Override public void onError(Exception e) { //client.close(); //this.logger.error("Hello Error:{}",e.getMessage()); } } ``` -------------------------------- ### 使用VideoTaskMonitor监控下载 Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d 通过监控中心插件获取VideoTaskMonitor实例,并记录下载字节数。 ```java //从监控中心插件获取对应任务id的监控 PluginCheckAndDo.CheckAndDo((plugin)->{ VideoTaskMonitor monitor = ((MonitorCenter) plugin).getInitMonitor(taskId, VideoTaskMonitor.class); if(monitor!=null){ monitor.addDownloadedBytes(bytes); //写入下载字节数 } }, PluginName.TASK_MONITOR_PLUGIN); ``` -------------------------------- ### 扩展自定义LoadConfig Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d 通过继承LoadConfig类,可以添加自定义的业务参数,例如视频路径或名称。 ```java public abstract class LoadVideoConfig extends LoadConfig { protected String videoPath; // 视频保存名称 protected String videoName; protected int clarity; public LoadVideoConfig(String videoPath, String videoName) { this.videoPath = videoPath; this.videoName = videoName; } } ``` -------------------------------- ### 定义爬虫配置类LoadConfig Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d 通过继承LoadConfig并添加@Creeper注解,将爬虫配置注册到CreeperCenter管理。 ```java @Creeper(creeperName = "豆瓣书籍top250",loadTask = DouBanLoadTask.class,creeperDescription = "爬豆瓣爬的",group="douban") public class DouBanLoadConfig extends LoadConfig { public DouBanLoadConfig() { this.url = "https://book.douban.com/top250"; //爬虫url //this.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36"; //this.Origin = "https://live.bilibili.com"; //this.Referer = "https://live.bilibili.com/"; } } ``` -------------------------------- ### Create a SpringBootPlugin Source: https://geniusay.github.io/ChopperBot-Doc/pages/c30e11 SpringBootPlugin allows the use of Spring annotations and simplifies initialization by removing the need for a complex constructor. ```java @Component public class Plugin extends SpringBootPlugin { @Override public boolean init() { //代码 } } ``` -------------------------------- ### 使用TaskCenter调度爬虫任务 Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d 通过TaskCenter插件提交ReptileRequest请求,并配置任务完成后的回调函数。 ```java CommonPlugin plugin = InitPluginRegister.getPlugin(PluginName.TASK_CENTER_PLUGIN); //获取TaskCenter插件 ReptileRequest request = new ReptileRequest(new DouyuHotModuleConfig(), //需要调度爬虫方法的参数文件 (t)->{System.out.println("return val:"+t)} //爬虫任务完成后的callback方法 ) ((TaskCenter)plugin).request(request); ``` -------------------------------- ### FileUtil API Source: https://geniusay.github.io/ChopperBot-Doc/pages/779a6e Utility class for performing file system operations such as checking existence, copying, and deleting files or directories. ```APIDOC ## FileUtil Methods ### isFileExist - **Description**: Checks if a file exists. - **Parameters**: dir (String) - File path. - **Returns**: boolean ### copyFile - **Description**: Copies a file from source to destination. - **Parameters**: srcPath (String) - Source path, destPath (String) - Destination path. - **Returns**: File ### deleteFile - **Description**: Deletes a file. - **Parameters**: path (String) - Root path, filename (String) - File name OR path (String) - File path. - **Returns**: boolean ### deleteDirectory - **Description**: Deletes a directory and its contents. - **Parameters**: path (String) - Directory path. - **Returns**: boolean ``` -------------------------------- ### 创建 SpringPluginInitMachine 启动器 Source: https://geniusay.github.io/ChopperBot-Doc/pages/c30e11 适用于 SpringBootPlugin 插件,需在类上添加 @Plugin 和 @Component 注解。 ```java @Plugin(moduleName = 所属模块名, pluginName = 插件名称, needPlugin = {所依赖的插件}, pluginName_CN = 插件中文名(不必要), pluginDescription = 插件描述(不必要), pluginClass= 要初始化的插件类, springBootPlugin = true ) @Component public class PluginInitMachine extends SpringPlugInitMachine{ } ``` -------------------------------- ### InitPluginRegister API Source: https://geniusay.github.io/ChopperBot-Doc/pages/c30e11 Methods for querying and managing plugin registration status and information within the global registry. ```APIDOC ## InitPluginRegister ### Description Provides access to the global plugin registry to retrieve plugin information, check registration status, and register new plugins. ### Methods - **InitPluginRegister.allPlugin**: Returns all registered plugins. - **InitPluginRegister.modulePlugin.get(moduleName)**: Retrieves all plugins under a specific module. - **InitPluginRegister.fatherAndSonPlugin.get(pluginName)**: Retrieves all sub-plugins for a given plugin. - **InitPluginRegister.moduleFatherAndSonPlugin.get(pluginName)**: Retrieves all sub-plugins within the same module as the specified plugin. - **InitPluginRegister.isRegister(pluginName)**: Returns boolean indicating if a plugin is registered. - **InitPluginRegister.getPlugin(pluginName)**: Returns the running instance of a plugin. - **InitPluginRegister.register(CommonInitMachine)**: Registers a new plugin launcher. ``` -------------------------------- ### Define ConfigFile structure Source: https://geniusay.github.io/ChopperBot-Doc/pages/e3a691 The base JSON structure required for all configuration files, containing an update timestamp and a data object. ```json { "updateTime": "最新更新时间", "data": {} } ``` -------------------------------- ### Manage FileCache Synchronization Source: https://geniusay.github.io/ChopperBot-Doc/pages/779a6c Register a FileCache instance with the manager for periodic synchronization or trigger a manual sync. ```java FileCacheManagerInstance.getInstance().addFileCache(你的文件缓存); ``` ```java fileCache.forceSync() ``` -------------------------------- ### 自定义监控器实现 Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d 通过继承CommonTaskMonitor并重写run方法,实现自定义的监控逻辑与数据推送。 ```java public class BarrageTaskMonitor extends CommonTaskMonitor { private int totalBarrage = 0; private int preDownloadBarrage = 0; public BarrageTaskMonitor() { monitorType = "barrage"; } public void addBarrage(int num){ preDownloadBarrage = num; totalBarrage += num; } @Override public void run() { if(handler!=null){ handler.wrapperAndSend( Map.of( "taskId",getTaskId(), "monitor",monitorType, "pre",preDownloadBarrage, "total",totalBarrage, "type","barrage", "useTime",timeConsuming(), "time", LocalDateTime.now() ),getTaskId() ); } } } ``` -------------------------------- ### ChopperBot爬虫模块目录结构 Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d 展示了在模块core目录下构建爬虫功能所需的必要文件夹结构。 ```text +-- ChopperBot | +-- 模块名 | | +-- core | | | +-- creeper | | | | +-- builder //爬虫文件构造器 | | | | +-- group //爬虫组 | | | | +-- loadconfig //爬虫参数文件(必要) | | | | +-- loadtask //爬虫主体任务(必要) | | | | +-- processor //后续任务处理(必要) | +-- 模块名 ``` -------------------------------- ### 使用BarrageTaskMonitor监控弹幕 Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d 通过监控中心插件获取BarrageTaskMonitor实例,并记录下载的弹幕数量。 ```java //从监控中心插件获取对应任务id的监控 PluginCheckAndDo.CheckAndDo(plugin -> { BarrageTaskMonitor monitor = ((MonitorCenter) plugin).getInitMonitor(this.loadBarrageConfig.getTaskId(), BarrageTaskMonitor.class); if(monitor!=null){ monitor.addBarrage(barrageNume); //写入下载弹幕数量 } }, PluginName.TASK_MONITOR_PLUGIN); ``` -------------------------------- ### PluginCheckAndDo API Source: https://geniusay.github.io/ChopperBot-Doc/pages/c30e11 Utility methods for conditional execution based on the presence of specific plugins. ```APIDOC ## PluginCheckAndDo ### Description Utility class to check if a plugin exists and execute logic accordingly. ### Methods - **CheckAndDo(success, pluginName)**: Executes success function if plugin exists. - **CheckAndDo(success, fail, pluginName)**: Executes success function if plugin exists, otherwise executes fail function. - **CheckAndGet(success, pluginName, resClazz)**: Executes success function if plugin exists and returns the result. ``` -------------------------------- ### 使用CreeperManager获取爬虫脚本 Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d 通过CreeperManager插件根据名称或配置获取已注解的爬虫脚本任务。 ```java CreeperManager manager = InitPluginRegister.getPlugin(PluginName.CREEPER_MANAGER_PLUGIN); //获取CreeperManager插件 //根据名字获取爬虫脚本 LoadTask task1 = manager.getLoadTask("豆瓣脚本") //根据爬虫请求中的LoadConfig获得爬虫脚本 LoadTask task2 = manager.getLoadTask(ReptileRequest) ``` -------------------------------- ### JsonFileUtil API Source: https://geniusay.github.io/ChopperBot-Doc/pages/779a6e Utility class for reading and writing JSON files, including support for large JSON files and object serialization. ```APIDOC ## JsonFileUtil Methods ### readJsonFile - **Description**: Reads a JSON file. - **Parameters**: filePath (String) - Root path, fileName (String) - File name OR fullPath (String) - Full path. - **Returns**: Map ### readJsonFileToJSONObject - **Description**: Reads a JSON file and returns a JsonObject. - **Parameters**: filePath (String) - Root path, fileName (String) - File name OR fullPath (String) - Full path. - **Returns**: JsonObject ### readJsonFileToObject - **Description**: Reads a JSON file and maps it to an object. - **Parameters**: fullPath (String) - Full path, clazz (Class) - Target class. - **Returns**: T (Generic) ### writeJsonFile - **Description**: Writes content to a JSON file, creating it if it does not exist. - **Parameters**: filePath (String) - Path, fileName (String) - Name, data (Map) - Content OR fullPath (String) - Full path, data (Map) - Content. - **Returns**: File ### writeJsonFileIsExist - **Description**: Writes to a JSON file if it exists, otherwise returns null. - **Parameters**: filePath (String) - Path, fileName (String) - Name, data (Map) - Content OR fullPath (String) - Full path, data (Map) - Content. - **Returns**: File ### writeBigJsonFile - **Description**: Writes a large JSON file. - **Parameters**: fullPath (String) - Full path, data (Map/List) - Content. - **Returns**: File ``` -------------------------------- ### Write Data to Cache Source: https://geniusay.github.io/ChopperBot-Doc/pages/779a6c Update specific keys or append to arrays within the cached file content. ```java fileCache.writeKeys(data,"account","src"); //更改文件内容 fileCache.writeKeys(data,"account","list","0"); //更改数组内容 fileCache.writeKeys(data,"account","list","-1"); //追加数组内容 ``` -------------------------------- ### Register a crawler with @Creeper Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d Use the @Creeper annotation to assign a crawler to a specific functional group and set its priority. ```java @Creeper(creeperName = "斗鱼热门模块", loadTask = DouBanLoadTask.class, creeperDescription = "爬斗鱼热门模块", priority = 10, //不必要,默认5 group="douyu_hot_module") ``` -------------------------------- ### Define a custom crawler functional group Source: https://geniusay.github.io/ChopperBot-Doc/pages/63a89d Extend AbstractCreeperGroup to create a custom functional group for crawlers. ```java @Component public class TikTokLiveGroup extends AbstractCreeperGroup { @Override public String getPlatform() { return "tiktok"; } @Override public String getFunctionName() { return "live"; } } ``` -------------------------------- ### Append Data to Cache Source: https://geniusay.github.io/ChopperBot-Doc/pages/779a6c Append content to specific sections or arrays within the cached file. ```java fileCache.append(i,"sectionwork","src","0"); //追加数组的某个元素 fileCache.append(i,"sectionwork","src","-1"); //追加数组 fileCache.append(i,"barrage","src"); //追加类中的元素 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.