我正在尝试使用java和JSOUP实现webcrawler。我有以下Html内容
<div class="backgroundSection">
<span class="lndustryProductLinks">
<span class="backgroundDetailHeading">Industry: </span><a class="criterion" rel="nofollow" href="#industryList=[{value:'66826',isUsed:true}]&level=0&type=company">Automotive Service & Collision Repair</a>
,
<a class="criterion" rel="nofollow" href="#industryList=[{value:'1290',isUsed:true}]&level=0&type=company">Consumer Services</a>
</span>
</div>
<div class="backgroundSection">
<span class="backgroundDetailHeading">Products and Services: </span>
`<span class="lndustryProductLinks"><a class="criterion"`href="#industryKeywords='windshield auto glass replacement services'&level=0&type=company" rel="NOFOLLOW">windshield auto glass replacement services</a>`
<a class="criterion" href="#industryKeywords='free mobile windshield repair services'&level=0&type=company" rel="NOFOLLOW">free mobile windshield repair services</a>
,
<a class="criterion" href="#industryKeywords='local automotive glass services'&level=0&type=company" rel="NOFOLLOW">local automotive glass services</a></span></div>
当我尝试使用以下代码获取行业链接(消费者服务)时:
public String getIndustry(String url)
{
String text=null;
String nilav=null;
try
{
doc=Jsoup.connect(url).get();
Elements e=doc.getElementsByClass("backgroundDetailHeading");
text=e.text();
}
catch(IOException e)
{
e.printStackTrace();
}
return text;
}
我也获得了div类产品和服务的链接。但我只想要工业div类的标准类值。我怎么能这样做?