Search code examples
javascripthtmldelphiindy10

I'm stumped trying to access data from a web page in software


I'm using Indy 10 in Delphi 7 to attempt to access some data from a hardware device on our local network, but accessing the HTML page using TIdHTML.Get() only returns the base code and not the page that is displayed by browsers.

I've saved the HTML and JS files to a web server so you can look at them. Also includes a screen shot of what it looks like in a browser.

https://stationplaylist.com/temp/stl_status.html

https://stationplaylist.com/temp/stl_status.js

https://stationplaylist.com/temp/stl_status.jpg

I just want to know if the Incoming Stream Status is ON or OFF, but no idea how to access it. I hope it is possible somehow using Indy.


Solution

  • You have to understand that downloading is one thing (which you do with Indy10) and interpreting the download(s) is another (which your internet browser does). A short journey into what your web browser does:

    • Parsing the downloaded stl_status.html, discovering HTML elements with attributes like src= which implies to download those files, too.
    • From the HTML page you can see that in stl_status.js the function afterLoad() is called, which indirectly executes get_Status(), which calls loadDoc('/stl_data.html') (oh wait, isn't that a file we yet haven't looked at?), which (of course) does a HTTP call itself to just download that file.

    Most likely you don't need to go that way, but can download stl_data.html directly and process it as per its layout (the JS file's code should be easy to understand for you).

    I repeat: downloading files does not imply rendering a website.