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.

32 lines
795 B

package strategy;
import model.Article;
import util.HttpUtil;
import exception.SpiderException;
public class BingStrategy implements CrawlStrategy {
@Override
public String getName() {
return "必应搜索";
}
@Override
public String getUrl() {
return "https://cn.bing.com/";
}
@Override
public Article crawl() throws SpiderException {
String html = HttpUtil.get(getUrl(), "UTF-8");
String title = HttpUtil.extractTagSafe(html, "<title>", "</title>");
Article article = new Article();
article.setTitle(title);
article.setContent("微软必应搜索引擎首页");
article.setUrl(getUrl());
article.setSource(getName());
return article;
}
}