本文整理汇总了Java中com.sun.syndication.feed.synd.SyndEntry.getLink方法的典型用法代码示例。如果您正苦于以下问题:Java SyndEntry.getLink方法的具体用法?Java SyndEntry.getLink怎么用?Java SyndEntry.getLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.syndication.feed.synd.SyndEntry
的用法示例。
在下文中一共展示了SyndEntry.getLink方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SyndEntryAdapter
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
public SyndEntryAdapter(SyndFeed feed, SyndEntry entry) {
if (entry.getTitleEx() != null) {
this.title = entry.getTitle();
this.titleType = entry.getTitleEx().getType();
}
if (entry.getDescription() != null) {
this.description = entry.getDescription().getValue();
this.descriptionType = entry.getDescription().getType();
}
this.uri = entry.getUri();
this.author = entry.getAuthor();
this.link = entry.getLink();
if (entry.getPublishedDate() != null)
this.publishedDate = ISO_8601_DATE_FORMAT.format(entry.getPublishedDate());
if (entry.getUpdatedDate() != null)
this.updatedDate = ISO_8601_DATE_FORMAT.format(entry.getUpdatedDate());
this.fetchDate = ISO_8601_DATE_FORMAT.format(new Date());
this.sourceLink = feed.getLink();
this.sourceUri = feed.getUri();
this.sourceTitle = feed.getTitle();
this.language = feed.getLanguage();
this.sourceType = feed.getFeedType();
}
示例2: gatherLinks
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
private TreeMap gatherLinks(String section) {
TreeMap linkMap = new TreeMap(Collections.reverseOrder());
//for sites that support rss we do rss
SyndFeed feed = getSectionLinksFromRssFeed(section);
if (feed != null) {
for (SyndEntry anEntry : (List<SyndEntry>) feed.getEntries()) {
String aLink = anEntry.getLink();
if (aLink.contains(ampLiteral)) {
aLink = aLink.replace(ampLiteral, "");
}
if (!shoudRemove(anEntry)) {
linkMap.put(aLink, aLink);
}
}
}
//for sites that do not have or do not support
return linkMap;
}
示例3: read
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
public void read() {
try {
URL source = new URL(Defaults.FEEDURL);
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(source));
@SuppressWarnings("unchecked")
List<SyndEntry> entries = feed.getEntries();
urls = new ArrayList<String>();
for(SyndEntry entry : entries) {
String sURL = entry.getLink();
urls.add(sURL);
} // for
} catch (IllegalArgumentException | FeedException | IOException e) {
e.printStackTrace();
}
long seed = System.nanoTime();
Collections.shuffle(urls, new Random(seed));
}
示例4: RSSPost
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
public RSSPost(SyndEntry rssEntry) {
if(rssEntry == null || rssEntry.getLink() == null)
return;
//Id
id = rssEntry.getLink();
//Document's title
title = rssEntry.getTitle();
//Document's content - Extract text content from html structure
if(rssEntry.getDescription()!=null)
description = extractDocumentContent(rssEntry.getDescription().getValue());
//Document's time of publication
creationDate = rssEntry.getPublishedDate();
//The url where the document can be found
url = rssEntry.getLink();
}
示例5: newFeedItemWithKey
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
public FeedItem newFeedItemWithKey(SyndEntry syndEntry)
throws CrawlerException
{
log.info("newFeedItemWithKey(): create new FeedItem: {}", syndEntry.getLink());
URL url = null;
try
{
url = new URL(syndEntry.getLink());
}
catch (MalformedURLException e)
{
log.info("Feed doesn't have a valid link: {}", syndEntry.getLink());
throw new CrawlerException(e);
}
FeedItem feedItem = new FeedItemImpl();
feedItem.setLink(url);
feedItem.setKey(syndEntry.getLink());
return feedItem;
}
示例6: handleChannelMessage
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
@Override
protected void handleChannelMessage(Connection connection, String channel, String fromNickname, String text, List<String> textAsList, Message message,
HandlerContext handlerContext) throws Exception {
String url = getUrl(textAsList, handlerContext);
SyndEntry latestEntry = getLatestEntry(url);
if (latestEntry == null) return;
String entryLink = latestEntry.getLink();
if (entryLink == null) {
entryLink = latestEntry.getUri();
}
if (entryLink == null) {
if (Config.LOGD) Log.d(TAG, "handleChannelMessage Could not get link for this entry");
return;
}
String entryTitle = latestEntry.getTitle();
connection.send(Command.PRIVMSG, channel, entryTitle + " " + entryLink);
}
示例7: RSSItem
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
public RSSItem(SyndEntry rssEntry) {
super(NewsFeedSource.RSS.toString(), Operation.NEW);
if(rssEntry == null || rssEntry.getLink() == null)
return;
//Id
id = rssEntry.getLink();
//Document's title
title = rssEntry.getTitle();
//Document's content - Extract text content from html structure
if(rssEntry.getDescription()!=null)
description = extractDocumentContent(rssEntry.getDescription().getValue());
//Document's time of publication
publicationTime = rssEntry.getPublishedDate().getTime();
//The url where the document can be found
url = rssEntry.getLink();
}
示例8: getAllPostsFromFeed
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
public static List getAllPostsFromFeed(String urlToGet, String source) throws IOException, FeedException {
ArrayList<BlogPost> posts = new ArrayList<BlogPost>();
URL url = new URL(urlToGet);
SyndFeedInput input = new SyndFeedInput();
try {
SyndFeed feed = input.build(new XmlReader(url));
int items = feed.getEntries().size();
if (items > 0) {
log.info("Attempting to parse rss feed: " + urlToGet);
log.info("This Feed has " + items + " items");
List<SyndEntry> entries = feed.getEntries();
for (SyndEntry item : entries) {
if (item.getContents().size() > 0) {
SyndContentImpl contentHolder = (SyndContentImpl) item.getContents().get(0);
String content = contentHolder.getValue();
if (content != null && !content.isEmpty()) {
BlogPost post = new BlogPost(content, null, null, source, item.getLink(), item.getUri(), null);
posts.add(post);
}
}
}
}
return posts;
}
catch(Exception ex){
log.error(ex);
return posts;
}
}
示例9: apply
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
@Override
public FeedEntry apply(SyndEntry entry) {
if (entry.getDescription() == null) {
return null;
}
String title = entry.getTitle();
String link = entry.getLink();
String description = entry.getDescription().getValue();
Date publishedDate = entry.getPublishedDate();
return new FeedEntry(title, link, description, publishedDate);
}
示例10: exchange
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
private void exchange(@NotNull SyndEntry feedEntry) {
try {
String link = feedEntry.getLink();
if (isNotBlank(link)) {
String pageContent = loadPageContent(link);
String extractedPageContent = new PageContentExtractor(includeCssSelector)
.extractPageElements(pageContent, link)
.cleanHtml()
.getMergedPageElements();
applyNewContentToEntry(feedEntry, extractedPageContent);
}
} catch (IOException | IllegalStateException e) {
logger.warn(String.format("Failed to load link '%s'.", feedEntry.getLink()), e);
}
}
示例11: fetchAndSave
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
public AbstractMap.SimpleEntry<Integer, Integer> fetchAndSave() throws Exception {
URL url = new URL(this.url);
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(url));
int items = feed.getEntries().size();
if(items > 0){
log.info("Attempting to parse rss feed: "+ this.url );
log.info("This Feed has "+items +" items");
}
List <SyndEntry> entries = feed.getEntries();
for (SyndEntry item : entries){
log.info("Title: " + item.getTitle());
log.info("Link: " + item.getLink());
SyndContentImpl contentHolder = (SyndContentImpl) item.getContents().get(0);
String content = contentHolder.getValue();
//content might contain html data, let's clean it up
Document doc = Jsoup.parse(content);
content = doc.text();
try {
Result result = ld.detectLanguage(content, language);
if (result.languageCode.equals(language) && result.isReliable) {
FileSaver file = new FileSaver(content, this.language, "bs", item.getLink(), item.getUri(), String.valueOf(content.hashCode()));
String fileName = file.getFileName();
BlogPost post = new BlogPost(content,this.language,null,"bs",item.getLink(),item.getUri(),fileName);
if(DAO.saveEntry(post)) {
file.save(this.logDb);
numOfFiles++;
wrongCount = 0;
}
}
else{
log.info("Item " + item.getTitle() + "is in a diff languageCode, skipping this post "+ result.languageCode);
wrongCount ++;
if(wrongCount > 3){
log.info("Already found 3 posts in the wrong languageCode, skipping this blog");
}
break;
}
}
catch(Exception e){
log.error(e);
break;
}
}
return new AbstractMap.SimpleEntry<>(numOfFiles,wrongCount);
}
示例12: parse
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void parse() throws Exception {
SyndFeedInput input = new SyndFeedInput();
byte b[] = downloadAndSendBinary(url);
if (b != null) {
SyndFeed feed = input.build(new XmlReader(new ByteArrayInputStream(b)));
name = feed.getTitle();
if (feed.getCategories() != null && feed.getCategories().size() > 0) {
SyndCategory category = (SyndCategory) feed.getCategories().get(0);
tempCategory = category.getName();
}
List<SyndEntry> entries = feed.getEntries();
for (SyndEntry entry : entries) {
tempItemTitle = entry.getTitle();
tempItemLink = entry.getLink();
tempFeedLink = entry.getUri();
tempItemThumbURL = null;
ArrayList<Element> elements = (ArrayList<Element>) entry.getForeignMarkup();
for (Element elt : elements) {
if ("group".equals(elt.getName()) && "media".equals(elt.getNamespacePrefix())) {
List<Content> subElts = elt.getContent();
for (Content subelt : subElts) {
if (subelt instanceof Element) {
parseElement((Element) subelt, false);
}
}
}
parseElement(elt, true);
}
List<SyndEnclosure> enclosures = entry.getEnclosures();
for (SyndEnclosure enc : enclosures) {
if (StringUtils.isNotBlank(enc.getUrl())) {
tempItemLink = enc.getUrl();
}
}
manageItem();
}
}
setLastModified(System.currentTimeMillis());
}
示例13: createFeedEntry
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
protected FeedEntry createFeedEntry(long id, SyndEntry syndEntry, long currentTime) {
String descriptionType = null;
String descriptionValue = null;
if (syndEntry.getDescription() != null) {
if (syndEntry.getDescription().getType() != null) {
descriptionType = syndEntry.getDescription().getType();
}
if (syndEntry.getDescription().getValue() != null) {
descriptionValue = syndEntry.getDescription().getValue();
}
}
// If we don't have description (summary on atom feed entry), use the first content item
if (descriptionValue == null && syndEntry.getContents().size() > 0) {
SyndContent content = syndEntry.getContents().get(0);
descriptionType = content.getType();
descriptionValue = content.getValue();
}
// Fallback to safe values
if (descriptionValue == null || descriptionValue.length() == 0
|| descriptionType == null || descriptionType.length() == 0) {
descriptionValue = FeedEntry.DEFAULT_DESCRIPTION_VALUE;
descriptionType = FeedEntry.DEFAULT_DESCRIPTION_TYPE;
}
// Proper MIME types
if (descriptionType.equals(Content.HTML)) {
descriptionType = "text/html";
} else if (descriptionType.equals(Content.TEXT)) {
descriptionType = "text/plain";
} else if (descriptionType.equals(Content.XHTML)) {
descriptionType = "application/xhtml+xml";
}
return new FeedEntry(
null,
id,
syndEntry.getLink(),
syndEntry.getTitle() != null && syndEntry.getTitle().length() > 0 ? syndEntry.getTitle() : FeedEntry.DEFAULT_TITLE,
syndEntry.getAuthor() != null && syndEntry.getAuthor().length() > 0 ? syndEntry.getAuthor() : FeedEntry.DEFAULT_AUTHOR,
currentTime,
syndEntry.getPublishedDate() != null ? syndEntry.getPublishedDate().getTime() : FeedEntry.DEFAULT_DATE,
syndEntry.getUpdatedDate() != null ? syndEntry.getUpdatedDate().getTime() : FeedEntry.DEFAULT_DATE,
descriptionType,
descriptionValue,
false
);
}
示例14: getFeedKey
import com.sun.syndication.feed.synd.SyndEntry; //导入方法依赖的package包/类
protected String getFeedKey(SyndEntry syndEntry)
{
return RedisKeys.FEED_KEY + syndEntry.getLink();
}