I want to make my KM macros more dynamic, without having to hard-code a lot of things. For example, I want my KM macro to fetch from the Internet series of strings like "the names of the planets", "the NATO phonetic alphabet", "the colours of the rainbow," "the names of the 50 US states," etc.
But when you use any search engine to do a search, the results are only a very small part of the page's results, often in inconvenient formals like multi-column tables. There's no way for me to easily isolate the actual answer programmatically. I'm unaware of any web search engine that does what I want - "just return the results". I even asked ChatGPT today, and it gave incorrect answers.
When Google first created Google Sheets, it had a feature that did what I wanted. For example, if I put the first items into a Google Sheets document, say, "Mercury", "Venus", and "Earth", I could select those words and stretch them out, and it used it's search engine savvy to populate the next fields with the remaining words, whatever they would be. As another example, I could put the words, "Kermit" and "Miss Piggy" in the first two cells in a table, and then when I stretched the table it would insert more names of muppets. This is very close to what I want. Perhaps with a little AppleScript programming a person could create a Google Sheet, insert a few terms, stretch the cells, and copy the results back to a KM variable.
Unfortunately I seem to have forgotten how to get Google Sheets to do this text expansion. Perhaps they have removed this feature, or hidden it in a submenu, or moved it into their "add-ons". Does anyone know where that feature is now? I've searched Google for "how do i get google sheets to produce similar items in new cells" and couldn't find the results. I've searched Google Sheets help for the same idea. I've searched their add-on library but found nothing.
STOP THE PRESS - as I write this post, I found an amazing function in Google Sheets that almost gives me what I want. The function is:
=IMPORTHTML("https://en.wikipedia.org/wiki/NATO_phonetic_alphabet","table",1,"en_US")
If you place the URL of the page that contains the data you want, this function will go to the page, fetch and isolate the data(!!!!!!), and place it into the cells of the spreadsheet. I see two downsides: (1) if the data in the web page is multi-column, it returns multiple columns of cells. (2) instead of a general web query, you have to use the actual URL of the page that contains the data.
I can probably live with problem #2, and I think I can use some KM programming to live with problem #1.
Google Sheets has a few functions like this that I never knew about. I'm really amazed. I think I may have to reconsider my aversion to using Google to process my data. The IMPORTHTML function also was able to return results from more complicated pages that I tested, but often with errors. I can mitigate these errors by finding the URL of a simple page that contains the information I need.
Remember, this is all being done to get my KM macros to be able to work more autonomously, without having to hard-code lots of constants. For example, I would like to create a KM macro that takes a short list of items, and uses the methods above to expand that short list into a longer or complete list. This would be a pretty awesome macro.