开发者

How to parse span title with jsoup?

开发者 https://www.devze.com 2023-04-12 00:30 出处:网络
i am trying to parse the title of this content using JSOUP.. <div class=\"article\"> <div class=\"articleHead review\">

i am trying to parse the title of this content using JSOUP..

<div class="article">
<div class="articleHead review">

    <h1 class="item"><span class="fn">OnLive</span> review</h1>
    &开发者_开发技巧lt;h2 class="subGrey"><span class=""></span>Cloud gaming has arrived in the UK, but can our infrastructure make the most of it?</h2>

I want to parse the span class OnLive Review. and the sub header

ive tried this so far..

 try{
                     Elements titleElements = jsDoc.getElementsByTag("div");
                         for(Element TitleElement : titleElements){
                             if(TitleElement.attr("class").equals("articleHeader review")){
                                 Element articleHeader = jsDoc.select("#item").first();
                                    String header = articleHeader.text();


                                        System.out.println(TitleElement.text());

                                       title = header.toString();
                                        Log.e("TITLE", title);

                                     }

                    }


                    }
                    catch(Exception e){
                        System.out.println("Couldnt get content");
                    }

No luck.


There you go:

Element header = jsDoc.select("h1.item span.fn");
Element sub = jsDoc.select("h2.subGrey span");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号