Skip to content

Instantly share code, notes, and snippets.

@donchan922
Last active August 18, 2018 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donchan922/5071c1de71f9b83cabef3fede1caf68e to your computer and use it in GitHub Desktop.
Save donchan922/5071c1de71f9b83cabef3fede1caf68e to your computer and use it in GitHub Desktop.
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