How to load a web page and manipulate it?

I need a push into the right direction please. My Web Core app needs to load a web page from a foreign web site, browse it's content ("screen scraping") and minipulate some of its content ("form filling") and "click" a button on this web page to post it's content. With Win32-regular Delphi, we loaded the page into a TWebBrowser component and used the components methods to manipulate the loaded DOM. How to do this with Web Core?

Any ideas would be very much appreciated.

Many thanks, Walter

In TMS WEB Core, there is a TWebBrowserControl and you can set the URL to the site you wan to navigate to.
Then you should be able to access the DOM of this IFRAME that is used underlying with something like:

asm
var elmnt = this.WebBrowserControl.ElementHandle.contentWindow.document.getElementsByTagName("H1")[0];
end;

Thank you Bruno!


http://www.toolfolks.com/TMSWeb/test1/Project12.html

procedure TForm10.WebButton1Click(Sender: TObject);

var

html,elmnt: String;

begin

asm

//class="product_price

// html = document.getElementById("WebBrowserControl1").contentDocument.documentElement.outerHTML;

elmnt = this.WebBrowserControl.ElementHandle.contentWindow.document.getElementsByClass("product_price")[0];

end;

WebMemo1.Text := elmnt;

end;

ERROR

Uncaught TypeError: Cannot read properties of undefined (reading 'ElementHandle') | TypeError: Cannot read properties of undefined (reading 'ElementHandle') at Object.WebButton1Click (http://localhost:8000/Project12/Project12.js:46002:39) at Object.cb [as FOnClick] (http://localhost:8000/Project12/Project12.js:245:19) at Object.Click (http://localhost:8000/Project12/Project12.js:30021:61) at Object.HandleDoClick (http://localhost:8000/Project12/Project12.js:29510:31) at HTMLButtonElement.cb (http://localhost:8000/Project12/Project12.js:241:26)

at http://localhost:8000/Project12/Project12.js [46002:39]

What is wrong here please ?

I see in your commented line you refer to as WebBrowserControl1 and in your next line WebBrowserControl?

elmnt = this.WebBrowserControl1.ElementHandle.contentWindow.document.getElementsByClass("row image-con")[0];

I have corrected that but get:

ERROR
Uncaught TypeError: Cannot read properties of undefined (reading 'contentWindow') | TypeError: Cannot read properties of undefined (reading 'contentWindow') at Object.WebButton1Click (http://localhost:8000/Project12/Project12.js:46011:54) at Object.cb [as FOnClick] (http://localhost:8000/Project12/Project12.js:245:19) at Object.Click (http://localhost:8000/Project12/Project12.js:30021:61) at Object.HandleDoClick (http://localhost:8000/Project12/Project12.js:29510:31) at HTMLButtonElement.cb (http://localhost:8000/Project12/Project12.js:241:26)
at http://localhost:8000/Project12/Project12.js [46011:54]

It is because document.getElementById("WebBrowserControl1") is null.
You can clearly see that in the browser console.
A component ID is NOT the same as a component.Name
If you inspect the elements, you'll see the IFRAME ID is TForm10_BrowserControl1.

And fwiw, when this IFRAME is on another domain (which it looks like), you won't be able to access its content this way as this is blocked by the browser.
Some background: