You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.2 KiB
36 lines
1.2 KiB
package com.crawler;
|
|
|
|
import com.crawler.controller.CrawlerController;
|
|
import com.crawler.crawler.Crawler;
|
|
import com.crawler.crawler.CrawlerFactory;
|
|
import com.crawler.model.CrawlerConfig;
|
|
|
|
public class TestRunner {
|
|
public static void main(String[] args) {
|
|
CrawlerFactory factory = CrawlerFactory.getInstance();
|
|
|
|
String[] testUrls = {
|
|
"https://www.hnu.edu.cn",
|
|
"https://news.hnu.edu.cn",
|
|
"http://www.weather.com.cn",
|
|
"https://www.mountblade.com.cn"
|
|
};
|
|
|
|
for (String url : testUrls) {
|
|
System.out.println("========================================");
|
|
System.out.println("测试 URL: " + url);
|
|
String crawlerName = factory.getCrawlerName(url);
|
|
System.out.println("选择爬虫: " + crawlerName);
|
|
|
|
Crawler crawler = factory.createCrawler(url);
|
|
CrawlerConfig config = new CrawlerConfig();
|
|
config.setTargetUrl(url);
|
|
|
|
CrawlerController controller = new CrawlerController(crawler);
|
|
controller.setConfig(config);
|
|
controller.execute();
|
|
|
|
System.out.println();
|
|
}
|
|
}
|
|
}
|