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.
33 lines
1.1 KiB
33 lines
1.1 KiB
import com.example.datacollect.*;
|
|
|
|
public class Main {
|
|
public static void main(String[] args) {
|
|
CrawlStrategy strategyA = new ASiteCrawlStrategyImpl();
|
|
CrawlStrategy strategyB = new BSiteCrawlStrategyImpl();
|
|
CrawlStrategy strategyC = new CSiteCrawlStrategyImpl();
|
|
CrawlStrategy strategyD = new DSiteCrawlStrategyImpl();
|
|
|
|
strategyA.crawl("http://www.example-a.com");
|
|
strategyB.crawl("http://www.example-b.com");
|
|
strategyC.crawl("http://www.example-c.com");
|
|
strategyD.crawl("http://www.example-d.com");
|
|
|
|
try {
|
|
throw new NetworkException("连接超时");
|
|
} catch (CrawlException e) {
|
|
System.out.println("捕获异常: " + e.getMessage());
|
|
}
|
|
|
|
try {
|
|
throw new ParseException("HTML格式错误");
|
|
} catch (CrawlException e) {
|
|
System.out.println("捕获异常: " + e.getMessage());
|
|
}
|
|
|
|
try {
|
|
throw new UnsupportedSiteException("UNKNOWN");
|
|
} catch (CrawlException e) {
|
|
System.out.println("捕获异常: " + e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
|