Jsoup with JavaScript dependent webpage?

Therefore, I am having trouble formulating the correct syntax for selecting this item from a web page. Here's what the path looks like on the Inspect Element Interface in Firefox

enter image description here

And here is what my current code looks like:

    Element prices = doc.select("body[class =en page-type-search page-type-group-shelf og ress] " +
                    "div#wrap " +
                    "div#main-wrap " +
                    "div#jalapeno-template " +
                    "div[class=zone zone3 wgrid-10of12 wgrid-6of8 wgrid-4of4] " +
                    "section#shelf-page " +
                    "div#shelf-thumbs " +
                    "div.shelf-thumbs " +
                    "div.price-current " +
                    "span.product-price-analytics").first();

            String priceOne = prices.attr("data-analytics-value");

And to be incredibly clear, the attribute I need is "data-analytics-value" because it gives an accurate price.

I think I have all the correct syntax, so what am I doing wrong? When I run the program, it gives me a nullPointerException. Any help is appreciated!

[ Update ] I changed princeOne to doc.toString () and said that the web browser does not work javascript and that JavaScript is needed to view the walmart website, any work around?

+4
1

Android WebView userAgent, , ,

    Jsoup.connect(url).get();

    Jsoup.connect(url).userAgent("YOUR_USER_AGENT_HERE").get();

. !

0

Source: https://habr.com/ru/post/1661009/


All Articles