It sounds like the website you’re automating is running on some kind of framework. While you technically can do everything with URLConnection it’s going to be challenging and I’d instead recommend you do it all in a DesktopHTMLViewer using Javascript.
You’d load your page, and then come up with a script to fill in the number in your ID field and click the find button, then run it with .ExecuteJavascript. Once the page has updated you prepare another javascript to extract the 10 fields you want and send them back to xojo using executeInXojo and capturing them with the JavascriptRequest event.
No API available - I only need a few of the many fields. Thank you Christian! I was floundering for a starting point. There are also a couple examples of XOJO with javascript that I can work from. Thank you for your detailed answer.
Not sure what OS you’re on, but this is the kind of thing that Microsoft Power Automate is pretty good at accomplishing with no coding required. You can then export the data into a csv or database to pass along to a companion Xojo app.
Christian, I now have an HTMLViewer window and have successfully logged in and copied the text of the page to parse into values. But I can’t figure out how to get individual values more efficiently from the HTMLViewer.
I have HTML of:
<a id=“ctl00_MainContentId_EmailLink” … >xxx@yyy.com
but:
Var c as New Clipboard
c=View.ExecuteJavaScriptSync(“document.getElementById(‘ctl00_MainContentId_EmailLink’).textElement”)
It’s tough to say for sure without actually seeing the code.
But one thing I’ve noticed that happens a lot is that your javascript ends up in a race condition with the page’s javascript that populates the values (whether it’s AJAX calls or some other framework, etc).
Your script may be working correctly, but it’s reading the values before they are set by the website.
You could use a timer to keep testing those elements until they are not empty, or maybe try a MutationObserver.
My code is running a minute or more after the page opens. What I just realized that is happening is that it is opening a new window of the same type and maybe the script is running against that window. Even the code “UWBrowser.SetFocus” initiates a new window instead of running the java against the original UWBrowser window. How can I address the original window?