September 07, 2010, 03:59:05 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  Home Help Media Affiliates Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Java rss grabber  (Read 1994 times)
0 Members and 1 Guest are viewing this topic.
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2620
Referrals: 13

WWW Awards
« on: August 01, 2008, 10:35:35 AM »

Code
GeSHi (java):
  1. /*--------------------------------------------------------------------------
  2. RssGrabber class
  3.  *****************
  4. By: HappyFace http://www.engineeringserver.com
  5. Contact: info [@] engineeringserver.com
  6. Version: unknown
  7. Last updated: 01/August/2008
  8. "*****************
  9. Note: a demo that grabs and shows rss feeds
  10. //----------------------------------------------------------------------*/
  11. import java.io.IOException;
  12. import java.net.MalformedURLException;
  13. import java.net.URL;
  14. import java.util.Collection;
  15. import java.util.Iterator;
  16.  
  17. import com.sun.cnpi.rss.elements.Item;
  18. import com.sun.cnpi.rss.elements.Rss;
  19. import com.sun.cnpi.rss.parser.RssParser;
  20. import com.sun.cnpi.rss.parser.RssParserException;
  21. import com.sun.cnpi.rss.parser.RssParserFactory;
  22.  
  23. public class RssGrabber {
  24. RssParser parser;
  25. Rss rss;
  26.  
  27. public static void main(String[] args){
  28. RssGrabber RG = new RssGrabber();
  29. try {
  30. RG.parser = RssParserFactory.createDefault();
  31. RG.rss = RG.parser.parse(new URL("http://www.engineeringserver.com/blog/feed"));
  32. RG.showBlogPost();
  33. } catch (RssParserException e) {
  34. e.printStackTrace();
  35. } catch (MalformedURLException e) {
  36. e.printStackTrace();
  37. } catch (IOException e) {
  38. e.printStackTrace();
  39. }
  40. }
  41.  
  42. public void showBlogPost(){
  43. Collection items = rss.getChannel().getItems();
  44. Iterator i = items.iterator();
  45. while(i.hasNext()){
  46. Item item = (Item)i.next();
  47. System.out.println("Title: " + item.getTitle());
  48. System.out.println("Link: " + item.getLink());
  49. System.out.println("Description: " + item.getDescription());
  50. }
  51. }
  52. }
  53.  
Created by GeSHI 1.0.7.20

output
Title: Tyrian, the best vertical shooter now free on your psp!
Link: http://www.engineeringser...ter-now-free-on-your-psp/
Description:
Tyrian, a vertical shooter pc game that i played on my 468 dx2 66mhz  years ago (yup those were the days!) Anyway, I was browsing the net a bit and noticed that this game went open source and someone converted the OpenTyrian version to the psp so guess what game i’m playing now? The [...]
Title: [NDS] Nintendo DS complete romlist!
Link: http://www.engineeringser...endo-ds-complete-romlist/
Description:
For those that are interested in the most up to date nintendo ds romlist, here’s a list i’ve posted on our forums that is compiled from various sources: http://www.engineeringser...+game+discussions-b114.0/
Note that we do NOT allow warez discussions on engineeringserver.com OR javaforums.net , the rom list is just for general purposes to see what games are out [...]
Title: Java ftp client sourcecode
Link: http://www.engineeringser...va-ftp-client-sourcecode/
Description: A simple ftp client that download files from a remote server, the functionalities are very basic (for demo purposes) but i'll work on more features later when I have the time. In the mean time you can play with it by downloading the sourcecode/classes below.
PLAIN TEXT
JAVA:


etc
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Javaforums.net :: a community about Java software development.
« on: August 01, 2008, 10:35:35 AM »

 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Your Ad Here
Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!
Page created in 0.225 seconds with 32 queries.

Google visited last this page Yesterday at 11:34:18 AM