I’m new here and I hope I’m not asking something which has already been answered. I have searched everywhere but am yet to discover an adequate answer.
My objective is fairly simple: I want to create a program which will stream the live gold and silver rates from: this website
How would I be able to pinpoint the values that I want to download? Currently, I have managed to implement this using Microsoft Excel’s web query feature wherein I am able to select a table from the webpage. However, I want to make it a standalone application.
By the way, I need to retrieve the rates to perform a calculation which is then displayed to the user.
I would greatly appreciate any ideas on how this can be achieved.
I think you need to
scrapeorparsethe data from your website. For that take a look at htmlcleaner, JSoup html parsers.You can use
XPathwith htmlcleaner to pinpoint the data.Here is a nice example Xpath Example.You can use firefox’s
firebugextension to get the xpath of an element. But your xpath is going to be very huge, by the look of the website you mentioned.Than you have to execute the code at specified interval of your choice.
And if there is
javascriptin play than you have to execute the javascript running behind the page using your java code.Try using
Rhinofrom Mozilla and using its integration libraries or by using the JDK 1.6ScriptEnginefacility.For
ScriptEngineExample take a look here- http://metoojava.wordpress.com/2010/06/20/execute-javascript-from-java/