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.
 
 

15 lines
471 B

package com.example.datacollect;
// 先定义爬虫策略接口(必须先建这个,否则ASiteCrawlStrategy会报错)
public interface ASiteCrawlStrategy {
void crawl(String url);
}
// A网站爬虫策略类(实现上面的接口)
class ASiteCrawlStrategyImpl implements CrawlStrategy {
@Override
public void crawl(String url) {
// 先写简单逻辑:打印爬取信息
System.out.println("正在爬取A网站:" + url);
}
}