Reputation: 497
im tring to get the text within a tag. I know its id, which is "lblCompra" and "lblVenta".
Document doc = Jsoup.connect("http://www.bccr.fi.cr//").get();
Element compra = doc.getElementById("lblCompra");
Element venta = doc.getElementById("lblVenta");
System.out.println(compra);
System.out.println(venta);
But what i get is bunch of text I dont need. Here's the output:
<span id="lblCompra"> <img src="images/waiting.gif" alt="cargando" /> </span>
<span id="lblVenta"> <img src="images/waiting.gif" alt="cargando" /> </span>
what i should be getting is like "400.0" and "450.0" or something like that.
Upvotes: 2
Views: 4249
Reputation: 2170
Maybe doc.getElementById("#lblCompra").innerHTML
will work?
Or if you want to get width and height of img, you can do this:
doc.getElementById('#lblCompra').getElementsByTagName('img')[0].width;
Upvotes: 0
Reputation: 1351
In order to get text value of an element try using text() method:
System.out.println(compra.text());
UPDATE: the value you are looking for is loaded by JavaScript. Consult this topic
Upvotes: 2
Reputation: 3212
if you use getElementById() ...you will get the element. Now that you have the element get the value from the element. Use the getValue() method to get the value
Upvotes: 0