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


Java SyndEntry.getLink方法代码示例

本文整理汇总了Java中com.rometools.rome.feed.synd.SyndEntry.getLink方法的典型用法代码示例。如果您正苦于以下问题:Java SyndEntry.getLink方法的具体用法?Java SyndEntry.getLink怎么用?Java SyndEntry.getLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.rometools.rome.feed.synd.SyndEntry的用法示例。


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

示例1: reload

import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
private void reload() {
//        System.out.println(feed);
        if (!incidents.isEmpty()) incidents.clear();
        for (SyndEntry entry : feed.getEntries()) {
            ServerStatusIncident incident = new ServerStatusIncident(entry.getTitle(), entry.getLink(), entry.getContents().get(0).getValue());
            if ((incident.contains(game) && incident.contains(platform)))
                incidents.add(incident);
        }
    }
 
开发者ID:stachu540,项目名称:HiRezAPI,代码行数:10,代码来源:StatusServer.java

示例2: getPublicationID

import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
private String getPublicationID(SyndEntry entry) {
    String link = entry.getLink();
    if (link == null) {
        LOGGER.warn("no link found in feed entry");
        return null;
    }
    link = link.trim();
    Matcher m = pattern2findID.matcher(link);
    if (m.matches()) {
        return m.group(1);
    } else {
        LOGGER.warn("no publication ID found in link {}", link);
        return null;
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:16,代码来源:MCRRSSFeedImporter.java

示例3: readFeeds

import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
public List<LinkBean> readFeeds(FeedBean feedBean){

        List<LinkBean> feeds = new ArrayList<LinkBean>();

        try {
            URL url = new URL(feedBean.getUrl());
            SyndFeedInput input = new SyndFeedInput();
            SyndFeed feed = input.build(new XmlReader(url));

            List<SyndEntry> entryList = feed.getEntries();

            for(SyndEntry syndEntry : entryList){
                URL linkUrl = new URL(syndEntry.getLink());

                LinkBean linkBean = new LinkBean();
                linkBean.setTitle(syndEntry.getTitle());
                linkBean.setUrl(linkUrl);
                linkBean.setPublicationDate(syndEntry.getPublishedDate());
                linkBean.setSent(false);
                linkBean.setSubreddit(feedBean.getSubreddit());
                linkBean.setFeedId(feedBean.getId());

                feeds.add(linkBean);
            }
            return feeds;
        } catch (Exception e) {
            logger.error(e.getMessage(),e);
        }
        return feeds;
    }
 
开发者ID:vitalijzad,项目名称:java-rss-for-reddit,代码行数:31,代码来源:RSSFeedReader.java

示例4: parseFeed

import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
private List<Outlink> parseFeed(String url, byte[] content,
        Metadata parentMetadata) throws Exception {
    List<Outlink> links = new ArrayList<>();

    SyndFeed feed = null;
    try (ByteArrayInputStream is = new ByteArrayInputStream(content)) {
        SyndFeedInput input = new SyndFeedInput();
        feed = input.build(new InputSource(is));
    }

    URL sURL = new URL(url);

    List<SyndEntry> entries = feed.getEntries();
    for (SyndEntry entry : entries) {
        String targetURL = entry.getLink();
        // targetURL can be null?!?
        // e.g. feed does not use links but guid
        if (StringUtils.isBlank(targetURL)) {
            targetURL = entry.getUri();
            if (StringUtils.isBlank(targetURL)) {
                continue;
            }
        }
        Outlink newLink = filterOutlink(sURL, targetURL, parentMetadata);
        if (newLink == null)
            continue;

        String title = entry.getTitle();
        if (StringUtils.isNotBlank(title)) {
            newLink.getMetadata().setValue("feed.title", title.trim());
        }

        Date publishedDate = entry.getPublishedDate();
        if (publishedDate != null) {
            // filter based on the published date
            if (filterHoursSincePub != -1) {
                Calendar rightNow = Calendar.getInstance();
                rightNow.add(Calendar.HOUR, -filterHoursSincePub);
                if (publishedDate.before(rightNow.getTime())) {
                    LOG.info(
                            "{} has a published date {} which is more than {} hours old",
                            targetURL, publishedDate.toString(),
                            filterHoursSincePub);
                    continue;
                }
            }
            newLink.getMetadata().setValue("feed.publishedDate",
                    publishedDate.toString());
        }

        SyndContent description = entry.getDescription();
        if (description != null
                && StringUtils.isNotBlank(description.getValue())) {
            newLink.getMetadata().setValue("feed.description",
                    description.getValue());
        }

        links.add(newLink);
    }

    return links;
}
 
开发者ID:eorliac,项目名称:patent-crawler,代码行数:63,代码来源:FeedParserBolt.java

示例5: nextTuple

import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
public void nextTuple() {
	
	// Fetch feeds only every 30 secs.
	long curtime = System.currentTimeMillis();
	if (this.lastFetchTimestamp != 0) {
		if (curtime - this.lastFetchTimestamp < 30000) {
			// A Spout's nextTuple() is called continuously in a loop by Storm. If there's nothing to do,
			// just exit the method so Storm can do other things like acking processed messages.
			return;
		}
	}
	LOG.info("Fetching comments for " + subreddit + " at " + curtime);
	
	SyndFeedInput input = new SyndFeedInput();
	SyndFeed feed = null;
	try {
		feed = input.build(new XmlReader(this.subredditCommentsfeedURL));
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
	this.lastFetchTimestamp = System.currentTimeMillis();
	LOG.info("Fetched " + feed.getEntries().size() + " comments for " + subreddit + " at " + this.lastFetchTimestamp);
	
	history.startBatch();
	
	for (SyndEntry s : feed.getEntries()) {
		String commentId = s.getUri();
		if (history.contains(commentId)) {
			LOG.info("Skip dupe " + subreddit + ":" + commentId);
			continue;
		}
		
		// An entry.link has the syntax:
		//	/r/[SUBREDDIT]/comments/[STORY-ID]/[STORY-PATH]/[COMMENT-ID]
		// We extract the story ID and story URL (that is everything except the [COMMENT-ID] at the end.
		// 
		// Story title can be extracted from entry.title which has the syntax:
		//	[AUTHOR] on [STORY TITLE]
		
		List<SyndContent> contents = s.getContents();
		if (contents != null && contents.size() > 0) {
			
			String link = s.getLink();
			String storyURL = link.substring(0, link.lastIndexOf("/")); 
			String[] parts = storyURL.split("/");
			String storyId = parts[4];
			
			String title = s.getTitle();
			String titlePrefix = s.getAuthor() + " on ";
			String storyTitle = title.substring(titlePrefix.length(), title.length());
			
			SyndContent cnt = contents.get(0);
			String comment = cnt.getValue();
			comment = Jsoup.clean(comment, Whitelist.none());
			comment = comment.replaceAll("\\p{Punct}", "");
			LOG.info("Emit {}:{}:{}:{}:{}:[{}]", subreddit, storyId, storyURL, storyTitle, commentId, comment);
			collector.emit(
					new Values(subreddit, storyId, storyURL, storyTitle, commentId, comment, this.lastFetchTimestamp), 
					commentId);
		}
		
		history.add(commentId);
		
	}
	
}
 
开发者ID:pathbreak,项目名称:reddit-sentiment-storm,代码行数:67,代码来源:SubredditCommentsSpout.java

示例6: parseRss

import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
/**
 * RSSの解析処理。
 * @param rss 1つのRSS情報
 * @return 解析後のLink情報
 * @throws FeedException Feedの解析失敗時の例外
 * @throws IOException IOException IO例外
 * @throws URISyntaxException URIの形式が不正な場合の例外
 * @throws CrawlerException Crawler共通例外
 */
@SuppressWarnings("deprecation")
public ArrayList<ArticleEntityBean> parseRss(RssEntityBean rss) throws IOException, FeedException,
                URISyntaxException, CrawlerException {
    log.info("start feed parse : " + rss.url);
    SyndFeed feed = null;
    feed = buildSyndFeed(new URI(rss.url));
    ArrayList<ArticleEntityBean> result = new ArrayList<ArticleEntityBean>();
    TimeZone tz = TimeZone.getTimeZone("GMT");
    if (feed != null) {
        List<SyndEntry> entries = feed.getEntries();
        log.info("feed entries count : " + entries.size());
        for (Object obj : entries) {
            SyndEntry entry = (SyndEntry) obj;
            String link = entry.getLink();
            DateTime createdAt = new DateTime(entry.getPublishedDate(), tz);
            String createdAtStr = Util.formatIsoDate(createdAt);
            String title = org.apache.commons.lang.StringEscapeUtils.unescapeXml(entry.getTitle());

            log.info("article : " + title + " / " + createdAtStr + " / " + link);
            if (isExistArticle(link, createdAt)) {
                log.info("->  article already exists");
                continue;
            }
            log.info("->  article not exists");

            ArticleEntityBean article = new ArticleEntityBean();
            article.link = link;
            article.title = title;
            article.auther = entry.getAuthor();
            article.url = entry.getUri();
            article.createdAt = createdAt;
            String fixHour = Conf.getValue("fix_time");
            Date now = new Date();
            Date fixDate = new Date(now.getYear(), now.getMonth(), now.getDate(), Integer.parseInt(fixHour), 0);
            if (now.getTime() > fixDate.getTime()) {
                article.publishedAt = tomorrow;
            } else {
                article.publishedAt = today;
            }
            article.site = rss.site;
            article.type = rss.type;
            article.description = null;
            SyndContent sc = entry.getDescription();
            if (sc != null) {
                article.description = sc.getValue();
                if (rss.replaceCR != null) {
                    article.rawHTML = article.description.replaceAll("\n", rss.replaceCR);
                } else {
                    article.rawHTML = article.description;
                }
            }

            article.tags = rss.defaultTag;
            result.add(article);
        }
    } else {
        log.warn("feed parse error url : " + rss.site);
        throw new CrawlerException();
    }
    return result;
}
 
开发者ID:codefornamie,项目名称:namie-crawler,代码行数:71,代码来源:ArticleCrawler.java

示例7: getEntryLink

import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
public String getEntryLink(final Object o) {
    final SyndEntry e = (SyndEntry) o;
    return e.getLink();
}
 
开发者ID:rometools,项目名称:rome,代码行数:5,代码来源:SyndFeedTest.java

示例8: parse

import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
public FetchedFeed parse(String feedUrl, byte[] xml) throws FeedException {
	FetchedFeed fetchedFeed = new FetchedFeed();
	Feed feed = fetchedFeed.getFeed();
	List<FeedEntry> entries = fetchedFeed.getEntries();

	try {
		Charset encoding = FeedUtils.guessEncoding(xml);
		String xmlString = FeedUtils.trimInvalidXmlCharacters(new String(xml, encoding));
		if (xmlString == null) {
			throw new FeedException("Input string is null for url " + feedUrl);
		}
		xmlString = FeedUtils.replaceHtmlEntitiesWithNumericEntities(xmlString);
		InputSource source = new InputSource(new StringReader(xmlString));
		SyndFeed rss = new SyndFeedInput().build(source);
		handleForeignMarkup(rss);

		fetchedFeed.setTitle(rss.getTitle());
		feed.setPushHub(findHub(rss));
		feed.setPushTopic(findSelf(rss));
		feed.setUrl(feedUrl);
		feed.setLink(rss.getLink());
		List<SyndEntry> items = rss.getEntries();

		for (SyndEntry item : items) {
			FeedEntry entry = new FeedEntry();

			String guid = item.getUri();
			if (StringUtils.isBlank(guid)) {
				guid = item.getLink();
			}
			if (StringUtils.isBlank(guid)) {
				// no guid and no link, skip entry
				continue;
			}
			entry.setGuid(FeedUtils.truncate(guid, 2048));
			entry.setUpdated(validateDate(getEntryUpdateDate(item), true));
			entry.setUrl(FeedUtils.truncate(FeedUtils.toAbsoluteUrl(item.getLink(), feed.getLink(), feedUrl), 2048));

			// if link is empty but guid is used as url
			if (StringUtils.isBlank(entry.getUrl()) && StringUtils.startsWith(entry.getGuid(), "http")) {
				entry.setUrl(entry.getGuid());
			}

			FeedEntryContent content = new FeedEntryContent();
			content.setContent(getContent(item));
			content.setCategories(FeedUtils.truncate(
					item.getCategories().stream().map(c -> c.getName()).collect(Collectors.joining(", ")), 4096));
			content.setTitle(getTitle(item));
			content.setAuthor(StringUtils.trimToNull(item.getAuthor()));
			SyndEnclosure enclosure = Iterables.getFirst(item.getEnclosures(), null);
			if (enclosure != null) {
				content.setEnclosureUrl(FeedUtils.truncate(enclosure.getUrl(), 2048));
				content.setEnclosureType(enclosure.getType());
			}
			entry.setContent(content);

			entries.add(entry);
		}
		Date lastEntryDate = null;
		Date publishedDate = validateDate(rss.getPublishedDate(), false);
		if (!entries.isEmpty()) {
			List<Long> sortedTimestamps = FeedUtils.getSortedTimestamps(entries);
			Long timestamp = sortedTimestamps.get(0);
			lastEntryDate = new Date(timestamp);
			publishedDate = (publishedDate == null || publishedDate.before(lastEntryDate)) ? lastEntryDate : publishedDate;
		}
		feed.setLastPublishedDate(publishedDate);
		feed.setAverageEntryInterval(FeedUtils.averageTimeBetweenEntries(entries));
		feed.setLastEntryDate(lastEntryDate);

	} catch (Exception e) {
		throw new FeedException(String.format("Could not parse feed from %s : %s", feedUrl, e.getMessage()), e);
	}
	return fetchedFeed;
}
 
开发者ID:Athou,项目名称:commafeed,代码行数:76,代码来源:FeedParser.java

示例9: formatNewsString

import com.rometools.rome.feed.synd.SyndEntry; //导入方法依赖的package包/类
/**
 * Formate un message contenant des informations contenu dans l'entrée donnée
 * @param entry l'entrée dont on doit récupérer les info
 * @return un message formaté contenant 
 */
private String formatNewsString(SyndEntry news)
{
    return "Titre : " + news.getTitle() + "\nLien : " + news.getLink();
}
 
开发者ID:NotAVeryIntelligentSystem,项目名称:NARVIS,代码行数:10,代码来源:TestReuters.java


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