Last active
August 18, 2018 10:39
-
-
Save donchan922/5071c1de71f9b83cabef3fede1caf68e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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