Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you read data off a webpage?

Status
Not open for further replies.

phatening

Programmer
Aug 8, 2005
18
US
Hello fellow programmers,

I would like to make a stock ticker or something similar but with different data. I believe the general algorithm to do this would be:
1) Develop a RSS aggregator and store it in a server.
2) Have the aggregator access data from a RSS or XML page.
3) Display the data in your ticker.

My question is how do you read the data off of a RSS or XML page using either java or php (the languages that i am most familiar with). I also know that there are predeveloped RSS Aggregators out there that are customizable, but I would like to build my own.

Thanks and I appreciate any feedback.
-Spence
 
Use a HttpUrlConnection object ...

Eg :

Code:
                                String url = "[URL unfurl="true"]http://www.google.com";[/URL]

                                HttpURLConnection c = (HttpURLConnection)(new URL(url).openConnection());
                                c.setRequestProperty("Connection","Keep-Alive");
                                c.setRequestMethod("GET");
                                c.setUseCaches(false);
                                c.connect();
                                BufferedReader br = new BufferedReader(new InputStreamReader(c.getInputStream()));
                                String line = "";
                                while ((line = br.readLine()) != null) {
                                        System.out.print(line +"\n");
                                }

                                br.close();
                                c.disconnect();



--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top