Skip to content

Instantly share code, notes, and snippets.

@donchan922 donchan922/FeedReader.java
Last active Aug 18, 2018

Embed
What would you like to do?
import java.net.URL;
// JavaのRSSライブラリ「ROME」をインポートする
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
public class FeedReader {
public static void main(String[] args) {
try {
// RSS情報を取得するURL
String url = "https://reasonable-code.com/rss";
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(new URL(url)));
// サイトのタイトル
System.out.println(feed.getTitle());
// サイトのURL
System.out.println(feed.getLink());
}
catch (Exception ex) {
ex.printStackTrace();
System.out.println("ERROR: "+ex.getMessage());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.