Document doc = Jsoup.connect("http://www.stockexchangeofmauritius.com/officialquotes/").get();
Element table = doc.select("table").get(0);
Elements trs = table.select("tr");
Iterator trIter = trs.iterator();
boolean firstRow = true;
trIter.next();
stmtt = conn1.createStatement();
if (count < 1) {
while (trIter.hasNext()) {
Element tr = (Element) trIter.next();
if (firstRow) {
firstRow = false;
continue;
}
Elements tds = tr.select("td");
Iterator tdIter = tds.iterator();
int tdCount = 1;
String symbol = null;
String trend = null;
String nominal = null;
while (tdIter.hasNext()) {
Element td = (Element) tdIter.next();
switch (tdCount++) {
case 1:
symbol = String.valueOf(td.text());
break;
case 2:
trend = td.getElementsByTag("img").get(0).absUrl("src");
break;
case 3:
nominal = String.valueOf(td.text());
break;
The img
tag is found in a td
of the table, thus I'm unable to get the text value. The code has been edited. Does .getElementsByTag returns a string value??? I have never did this for JSoup. Please advise.
Once you have the td tag in question you can use the following to retrieve the image src:
td.getElementsByTag("img").get(0).attr("src")
If you want the entire path including the website name use the following instead: td.getElementsByTag("img").get(0).absUrl("src")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.