Java 使用JSOUP从具有重复类名的HTML中提取信息?

Java 使用JSOUP从具有重复类名的HTML中提取信息?,java,jsoup,Java,Jsoup,我正在尝试使用java和JSOUP实现webcrawler。我有以下Html内容 <div class="backgroundSection"> <span class="lndustryProductLinks"> <span class="backgroundDetailHeading">Industry:&nbsp;</span><a class="criterion" rel="nofollow" href

我正在尝试使用java和JSOUP实现webcrawler。我有以下Html内容

<div class="backgroundSection">
        <span class="lndustryProductLinks">
  <span class="backgroundDetailHeading">Industry:&nbsp;</span><a class="criterion" rel="nofollow" href="#industryList=[{value:'66826',isUsed:true}]&amp;level=0&amp;type=company">Automotive Service &amp; Collision Repair</a>
                        ,
<a class="criterion" rel="nofollow" href="#industryList=[{value:'1290',isUsed:true}]&amp;level=0&amp;type=company">Consumer Services</a>
            </span>
        </div>

<div class="backgroundSection">
<span class="backgroundDetailHeading">Products and Services:&nbsp;</span>
`<span class="lndustryProductLinks"><a class="criterion"`href="#industryKeywords='windshield auto glass replacement services'&amp;level=0&amp;type=company" rel="NOFOLLOW">windshield auto glass replacement services</a>`
<a class="criterion" href="#industryKeywords='free mobile windshield repair services'&amp;level=0&amp;type=company" rel="NOFOLLOW">free mobile windshield repair services</a>
,


<a class="criterion" href="#industryKeywords='local automotive glass services'&amp;level=0&amp;type=company" rel="NOFOLLOW">local automotive glass services</a></span></div>

我也得到了div类产品和服务的链接。但我只想要工业部门的标准等级值。我该怎么做?

如果没有其他信息,很难回答这个问题。例如,您想要的div总是第一个吗?还是它总是被命名为“工业”?根据需要构造选择器。查看JSoup中的CSS选择器。如果没有其他信息,这很难回答。例如,您想要的div总是第一个吗?还是它总是被命名为“工业”?根据需要构造选择器。查看JSoup中的CSS选择器。
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;            
    }