java - How to get data from td with multiple classes using jsoup -
from web page i'm trying extract data contains following text in got stuck @ td mutiple classes. i'm unable data td of table multiple classes.
<div class="uia"> <div class="exa iqc"> <div class="wna fa-lsa ala"> <div class="cr aha">contact info</div> <div class="y4"> <table class="mlb"> <tbody> <tr> <td class="maa">address</td> <td class="qla adr"> <div class="phb"> <div> 1600 amphitheatre pkwy mountain view, ca 94043 united states </div> </div></td> </tr> <tr> <td colspan="2"></td> </tr> </tbody> </table> </div> </div> </div> </div>
i trying extract address in td class="qla adr". please me.
system.out.println("address : " +doc.select("div.uia > div.exa.iqc > div.wna.fa-lsa.ala > div.y4 > table[class=mlb] > tbody > tr > td[class=qla adr] > div").text());
you don't have use such complicated expression classes, can select them directly.
in addition, []
syntax selecting attributes - normal css selectors, classes selected prefixing name .
.
in case, assuming website loaded string (although load using connect
), text can use
document doc = jsoup.parse(soup); elements extractedclasses = doc.select(".qla.adr"); system.out.println(extractedclasses.text());
this prints out
1600 amphitheatre pkwy mountain view, ca 94043 united states
Comments
Post a Comment