Java爬虫框架 | 爬小说
Jsoup,Java爬虫解决方案,中文文档: jsoup 不得不说Java的生态真的好,原来我以为爬虫是只能用Pyhton来写的,结果发现Java的爬虫框架不要太多…… 一分钟你就可以写一个简单爬虫 WebMagic in Action 不过个人觉得Jsoup最好用,最直接也很简单 写了一个Demo,爬取笔趣网的小说,格式已过滤。 public class CrawlText { /*** * 获取文本 * * @param autoDownloadFile * 自动下载文件 * @param Multithreading * 多线程 默认false * @param Url * 网站链接 * @throws IOException */ public static void getText(boolean autoDownloadFile, boolean Multithreading, String Url) throws IOException { String rule = "abs:href"; List<String> urlList = new ArrayList<String>(); Document document = Jsoup.connect(Url) .timeout(4000) .ignoreContentType(true) .userAgent(