Downloader downloder = new SingleThreadDownloader();
String path = "out/万古神帝.txt";// 保存路径
String chapterListUrl = "http://www.booktxt.net/3_3571/";// 章节地址
downloader.download(chapterListUrl, path);// 整本书下载
String chapterUrl = "http://www.booktxt.net/3_3571/1292242.html";// 指定的章节
downloader.downloadSkipPrevChapters(chapterUrl, path);// 从指定的章节开始下载所有章节
int fixedThreadCount = 5;// 固定每次下载只用5个线程
Downloader downloder = MultiThreadDownloader.newFixedThreadCountDownloader(Executors.newCachedThreadPool(), fixedThreadCount);
int fixedTaskCount = 100;// 固定每个线程最多下载100章
downloader = MultiThreadDownloader.newFixedTaskCountDownloader(Executors.newCachedThreadPool(), fixedTaskCount);
- 实现Novel接口
可参考顶点小说实现
- 实现Chapter接口
可参考顶点小说实现
- 实现ChapterBody接口
可参考顶点小说实现
- 注册到工厂NovelFactory
NovelFactory.register("www.booktxt.net", BookTxtNovel.class, BookTxtChapterBody.class);
NovelFactory.register("www.example.com", ExampleNovel.class, ExampleChapterBody.class);