Getting data from a web site using Jsoup
-
The URL of the site is: https://www.lowes.com/pd/7-16-CAT-PS2-10-OSB-Sheathing-Application-as-4-x-8/50382768[^] The information that I am trying to obtain is the price. Using Chrome's Inspect view, I was able to drill down to the price element in question. The Xpath of that element looks like:
/html/body/div[3]/section/div/div[7]/div[1]/div[2]/div[1]/span/div[1]
I really wanted to see that in some "tree" form, so I walked the HTML backward from that element back to the top. That looks like:
$30.65
I was able to throw some Java code together (read: ugly) to drill down to that level but got stopped at the next-to-last
DIV
element.// a bunch of other calls to getElementsByAttributeValue()
...
Elements elements = element.getElementsByAttributeValue("class", "style__ProductTitleWrapper-PDP__sc-1a0l1ro-11 fUmbqY");This returns a 1-item collection as it should. If I then follow that with:
Element element = elements.get(0);
elements = element.getElementsByAttributeValue("class", "styles__PriceWrapper-sc-1c3t51u-0 ZQLLV priceWrapper");It returns an empty collection. I assume this is because no such class could be found. However I can plainly see that
DIV
element in the Inspect view. I can get the sibling elements to the one in question. I even tried searching forgetElementsByAttributeValue("tabindex", "0")
, and while it correctly found 2 elements, neither are the one I want. Any idea(s) as to what I'm missing (or not understanding)? Thanks. DC"One man's wage rise is another man's price increa
-
The URL of the site is: https://www.lowes.com/pd/7-16-CAT-PS2-10-OSB-Sheathing-Application-as-4-x-8/50382768[^] The information that I am trying to obtain is the price. Using Chrome's Inspect view, I was able to drill down to the price element in question. The Xpath of that element looks like:
/html/body/div[3]/section/div/div[7]/div[1]/div[2]/div[1]/span/div[1]
I really wanted to see that in some "tree" form, so I walked the HTML backward from that element back to the top. That looks like:
$30.65
I was able to throw some Java code together (read: ugly) to drill down to that level but got stopped at the next-to-last
DIV
element.// a bunch of other calls to getElementsByAttributeValue()
...
Elements elements = element.getElementsByAttributeValue("class", "style__ProductTitleWrapper-PDP__sc-1a0l1ro-11 fUmbqY");This returns a 1-item collection as it should. If I then follow that with:
Element element = elements.get(0);
elements = element.getElementsByAttributeValue("class", "styles__PriceWrapper-sc-1c3t51u-0 ZQLLV priceWrapper");It returns an empty collection. I assume this is because no such class could be found. However I can plainly see that
DIV
element in the Inspect view. I can get the sibling elements to the one in question. I even tried searching forgetElementsByAttributeValue("tabindex", "0")
, and while it correctly found 2 elements, neither are the one I want. Any idea(s) as to what I'm missing (or not understanding)? Thanks. DC"One man's wage rise is another man's price increa