Search code examples
web-scrapinggetelementbyidoffice-scripts

Webscraping through Office Scripts without API, using getElementByID, etc


Please assist: I'm familiar with VBA and C++, but not with Java. Now wanting to delve into Office Scripts.

However, I want to know if I can achieve the same as in VBA: I am logging into niche websites and fetching data in tables using VBA Internet Controls (getElementByID()), etc.

As far as I know, these niche websites do not have an API, as the sample scenario of webscraping on the Microsoft website does: https://learn.microsoft.com/en-us/office/dev/scripts/resources/scenarios/noaa-data-fetch

I would like to know if I can log onto these websites, and then fetch information using HTML (getElementByID()) or similar?

I am just unsure if I can use Office Scripts directly, or if I require to include some library or something.

Any guidance would be appreciated.


Solution

  • Currently, there is no way to do this through Office Scripts alone. The fetch command and REST APIs are the only ways to get data in a script directly from webservices. If you'd like to request the addition of a specific library, please use the Send feedback button in the Office Scripts Code Editor.

    The discussion in the comments about using Power Automate is a reasonable path to pursue. The linked video (https://www.youtube.com/watch?v=_O9eEotCT0U) is a good place to start.