Help with Scrape doesnt show Value ( Strong Tag )

Hello, I’m trying for a couple of days now to get the get occupancy percentage of my fitness studios website “scraped”. The Value I’m looking for is located between “strong” tags. When i check the sensor in devtools it just shows blank (not unknown or unavailable) in the logs I can’t see any error as well. It looks like it might have something to do with the “strong” Tag. I also tried to choose a different value e.g the text line “Aktuelle Auslastung” which is located between “div” tags and it shows up correctly in the sensor whit an equal configuration. Has anybody an idea about it?

the website is: Fitnessstudio Leipzig-Südvorstadt | FIT STAR

![scrape|690x323]

That percentage number is not in the original HTML, which is all that the scrape sensor can see. If you View Source rather than use F12 DevTools, you’ll see:

<div class="fs-livedata-percentage">
  <span class="fs-livedata-percentage-label">
    Aktuelle Auslastung:
  </span>
  <strong id="fs-livedata-percentage" class="yellow"></strong>
</div>

There is a Javascript file /typo3conf/ext/fitstar_t3_livedata/Resources/Public/Javascript/script.js that populates it after the page has loaded. I’m not sure where it’s sourcing the data from — that’d take a bit more digging to find.

    function updateLiveData(index) {
      // Dynamically change data
      fsLiveChart.data.datasets[0].data = live[index];
      // Update chart
      fsLiveChart.update();
      if ($("#fs-livedata-percentage").length) {
        $("#fs-livedata-percentage").html(Math.round(live[index]) + '%');
      }
    }

Thanks for the quick support. Oh okay, I understand the problem as you described, but im not that experienced with coding. Does that mean it’s not possible to get the value at all, or I have to use another datasource/ selector from your last post here:

function updateLiveData(index) {
  // Dynamically change data
  fsLiveChart.data.datasets[0].data = live[index];
  // Update chart
  fsLiveChart.update();
  if ($("#fs-livedata-percentage").length) {
    $("#fs-livedata-percentage").html(Math.round(live[index]) + '%');
  }
}

…sorry its a bit beyond my knowledge but im trying to get it :wink:

The number must come from somewhere. I’ve had a quick look and it’s not obvious where. “Not possible” is a strong phrase, but it may not be worth the effort.

haha okay …got it …but thanks for bringing some light on it …at least i dont need to spend more days and hours to figure out why its not working

Turns out it is in the original HTML. A few lines down from your <strong> element, there is:

    <script type="text/javascript">
        var live =  JSON.parse(JSON.stringify([[21]]));
        var studios = JSON.parse(JSON.stringify([{"studio_id":16,"studio_name":"FIT STAR Leipzig-Südvorstadt","today":["5","0.38461538461538","0.38461538461538","6.1538461538462","13.076923076923","25.384615384615","13.461538461538","29.230769230769"],"last_week":["5.7692307692308","1.1538461538462","0.38461538461538","9.6153846153846","15","21.923076923077","21.923076923077","23.076923076923","29.230769230769","38.461538461538","31.538461538462","24.230769230769"],"percentage":"29.230769230769","available":"184"}]));
    </script>  

That 21 in the first line is the number you want, I’m pretty sure. Here’s how to access it:

It’s very sensitive to the structure of the page, though. If they change the page at all, it’ll probably break.

WOW!! you are a Genius !! It’s working… thank u so much

1 Like