当前位置: 首页>>代码示例>>Java>>正文


Java SiteMapIndex类代码示例

本文整理汇总了Java中crawlercommons.sitemaps.SiteMapIndex的典型用法代码示例。如果您正苦于以下问题:Java SiteMapIndex类的具体用法?Java SiteMapIndex怎么用?Java SiteMapIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SiteMapIndex类属于crawlercommons.sitemaps包,在下文中一共展示了SiteMapIndex类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSitemapsForUrl

import crawlercommons.sitemaps.SiteMapIndex; //导入依赖的package包/类
public List<AbstractSiteMap> getSitemapsForUrl(String sitemapUrl) {
	List<AbstractSiteMap> sitemaps = new ArrayList<>();

	SiteMapParser siteMapParser = new SiteMapParser();
	try {
		Uri uri = Uri.create(sitemapUrl);
		Blob blob = Requesters.of(uri.getScheme()).get().get(uri);
		String contentType = blob.getMetadata().getContentMetadata().contentType() != null ? blob.getMetadata().getContentMetadata().contentType()
				: "text/xml";

		AbstractSiteMap sitemap = siteMapParser.parseSiteMap(contentType, IOUtils.toByteArray(blob.getPayload().openStream()), new URL(sitemapUrl));

		if (sitemap.isIndex()) {
			sitemaps.addAll(((SiteMapIndex) sitemap).getSitemaps());
		} else {
			sitemaps.add(sitemap);
		}
	} catch (Exception e) {
		log.debug("", e);
	}
	return sitemaps;
}
 
开发者ID:Treydone,项目名称:mandrel,代码行数:23,代码来源:AnalysisService.java

示例2: XMLIndexHandler

import crawlercommons.sitemaps.SiteMapIndex; //导入依赖的package包/类
XMLIndexHandler(URL url, LinkedList<String> elementStack, boolean strict) {
    super(elementStack, strict);
    sitemap = new SiteMapIndex(url);
    sitemap.setType(SitemapType.INDEX);
    loc = new StringBuilder();
}
 
开发者ID:crawler-commons,项目名称:crawler-commons,代码行数:7,代码来源:XMLIndexHandler.java


注:本文中的crawlercommons.sitemaps.SiteMapIndex类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。