java - Jsoup cant extract stock price from the webpage -


i have been using jsoup extract a stock price stock trading website. stock price updated automatically @ regular intervals. have tried using examples given in cookbook,,but have not been having luck please me out...

the following have tried...

import java.io.ioexception;  import org.jsoup.jsoup; import org.jsoup.nodes.document;   public class sup {      /**      * @param args      * @throws ioexception       */     public static void main(string[] args) throws ioexception {         // todo auto-generated method stub         string url="http://money.rediff.com/companies/selan-exploratio/17020281";         document doc = jsoup.connect(url).get();         string quote = doc.select("#ltpid .f22 span").first().text();         system.out.println(quote);     } } 

the stock price seems stored in span having id ltpid. using #ltpid selector sufficient. selector tries find span has ancestor class .f22 has ancestor id ltpid.

read http://jsoup.org/apidocs/org/jsoup/select/selector.html explanations selectors.

edit:

you have second problem though: span not inside document have loaded. it's inside iframe has following url: http://money.rediff.com/money1/current_stat.php?companycode=17020281.

try url instead of 1 you're using, , it'll work.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -