0

I'm doing some testing with the jsoup library on the PlayStation store website, and whether or not you can detect sales for certain games.

So far everything works great, as the game's webpage contains a certain span if it is on sale which can be detected by jsoup's selector:

    Element discountMark = doc.selectFirst("span.price-display__strikethrough");
    <span class="price-display__strikethrough">
      <div class="price">$19.99</div>
    </span>

Along with the span, the game's page will have a div with the class name price-availability to display the duration of the sale.

    <div class="price-availability">
      This price is only available from 9/30/2020 02:00 am to 10/15/2020 01:59 am.
    </div>

This price-availability div for some reason isn't able to be selected and returns an IllegalArgumentException:

    Element discountDate = doc.selectFirst("div.price-availability");

Even on the try.jsoup page it cannot be detected with "div.price-availability" as the selector. I'm using this store page for testing and this example.

I'm assuming the div is being loaded by an external script when the page loads, preventing jsoup from parsing the info directly, but I'm unsure of the details with how Jsoup.connect(url).get() exactly works.

It's not the biggest deal, just something I noticed and wanted to learn from! Also sorry for formatting, I don't post often.

  • 1
    Usually when some elements can't be found but seem to exist in DOM (by inspecting it via browser) then those elements are generated and added *dynamically* (by JavaScript, etc..). Jsoup is not browser emulator so it doesn't support JavaScript which means it will only see *original* version of document/DOM (before any JS modification). In such cases you may want to pick other tool like Selenium webdriver. – Pshemo Oct 08 '20 at 21:35
  • To confirm it try to disable JavaScript support for that page and then inspect DOM (or simply check visually if searched element is there or not). – Pshemo Oct 08 '20 at 21:37

0 Answers0