0

When I try to get the HTML source from this url : https://www.weatherlink.com/embeddablePage/show/44a2d6b116484f5a8013ffad079046b9/slim

If I request the source code to Chrome Navigator, I see :

< body class="embeddable-page-body">
< !-- Google Tag Manager (noscript) -->
< noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NLLVC3L" height="0" width="0" "display:none;visibility:hidden"></iframe></noscript>

< div class="embeddable-page-container">
< /div>

If I see Google inspector, I can read :

< div class="embeddable-page-container">
< div>
< div class="embeddable-page embeddable-page-slim">
< div class="container-fluid">
::before
< div class="row embeddable-page-header" style="height: 54px;">
::before
< span> Plage Thalès < /span>
< br>
< span class="conditions" id="conditionsUpdated" data-toggle="tooltip" title="Last successful refresh at 11:37 Jul 08,2023"> Conditions as of: 11:37 Saturday, Jul 08,2023 < /span>
::after
< /div>
< /div>

How to get the information inside the "embeddable-page-container" DIV and so on ? Or a more precise question : how to get the date of the last successful refresh, which is in '<span class="conditions" ...' inside "embeddable-page-container", inside "embeddable-page embeddable-page-slim", inside "container-fluid", inside "row embeddable-page-header slim-embeddable-page-header" ?

I tried with URLConnection and a BufferReader. I tried with Ion. I tied with jsoup.

In all cases, the result was an empty < div class="embeddable-page-container"> :

  • Sorry, a part of the copy/paste was interpreted. Here is what I received :
    – Stéphane Gauthier Jul 07 '23 at 12:58
  • You need an HTML parser to build the DOM where you can search for HTML elements. On Java on common that still works even if the page is not 100% compliant to the HTML spec is https://jsoup.org See e.g. https://stackoverflow.com/a/2835555/150978 – Robert Jul 07 '23 at 13:07
  • I tried '''Document doc = Jsoup.connect(url).get();" but when I try to search '''Elements elements = body.select(".embeddable-page-slim");''' Elements is still empty – Stéphane Gauthier Jul 07 '23 at 14:54
  • `embeddable-page-slim` is different from `embeddable-page-body` in your question, is this a typo? Print the HTML code retrieved by Jsoup to make sure you really get the same HTML file and the element you search is really present. – Robert Jul 07 '23 at 15:10
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jul 07 '23 at 19:02
  • First message updated. – Stéphane Gauthier Jul 08 '23 at 10:02

0 Answers0