简体   繁体   中英

how to find the inner elements when all div class name and span class name are same using jsoup in java

<div class="xyOfqd">
   <div class="hAyfc">
     <div class="BgcNfc">Updated</div>
       <span class="htlgb">
          <div>
             <span class="htlgb">July 14, 2018</span>
          </div>
       </span>
     </div>
   <div class="hAyfc">
     <div class="BgcNfc">Size</div>
     <span class="htlgb">
        <div><span class="htlgb">3.9M</span></div>
     </span>
  </div>
</div>

I want all the text from above html using jsoup in java.

Like this Updated July 14, 2018 Size 3.9M

updated and size are constant but date and 3.9M are dynamic values.

Basically I am trying to scrap the values from google play store.

You have two issues here:

  1. Finding the CSS selector of elements with the same name. This is the easier part, because they all have a different selector. If you use your browser's developer tools you will see that the selector of update is div.hAyfc:nth-child(1) > div:nth-child(1) and the selctor of size is div.hAyfc:nth-child(2) > div:nth-child(1) .
  2. Getting dynamic values - well, Jsoup cannot get dynamic values. You can try to find the ajax call that fetches those values and try to do the same with Jsoup, or use some other tool, like PhantomJS

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM