i'm trying to select some paragraph in www.zoho.com using following css paths:
- html > body > div:nth-of-type(2) > div:nth-of-type(3) > section > div > div > div > div
- div.zh-banner-wrap > div.content-wrap.animated:first-child
it is working fine in Chrome inspect element css path search
But while i'm trying this in jsoup it is not working.
Java code :
Document doc = Jsoup.connect("https://www.zoho.com").get();
Element el = doc.selectFirst("html > body > div:nth-of-type(2) > div:nth-of-type(3) > section > div > div > div > div");
if(el != null) {
System.out.println(el.text());
}
I am not sure what are expected output in your case. When I am using your selector in chrome console
document.querySelector("html > body > div:nth-of-type(2) > div:nth-of-type(3) > section > div > div > div")
I got null. Same as in Jsoup.
This is because
document.querySelector("html > body > div:nth-of-type(2)")
is
<div class="ztopstrip-container"></div>
If in your case output is different, check if there is a content loaded dynamically via JavaScript.
Compare result of System.out.println(doc.html())
with source code from web browser.