0

How can I obtain the HTML content of a page loaded in the Embedded Browser asset for Unity?

I have been trying to get the HTML content of a loaded page for the past three days without success.

I would greatly appreciate it if someone could provide me with some guidance on how to obtain the HTML content of a page loaded in the Embedded Browser asset. Is there a specific function or method that I should be using? Or is there some other way to access the HTML content?

Thank you in advance for any help or advice that can be provided.

I have been trying to get the HTML content of a loaded page.

Is there a specific function or method that I should be using? Or is there some other way to access the HTML content?

Clifford
  • 88,407
  • 13
  • 85
  • 165
  • From what I can read on the [Embedded Browser documentation](https://zenfulcrum.com/browser/docs/Readme.html), you can call native JS functions from the `Browser` in your scene. I'd guess that you can call `document.querySelector` as well to access an element inside the DOM like this: `browser.CallFunction("document.querySelector(#id-you-want-to-access).Then(ret => { do something with the result });". – Velorexe Mar 08 '23 at 08:13
  • i will try it thank you, if it works i will reply again – ShadowlessGT Mar 08 '23 at 11:01
  • i tryed it in the following way but it never jumps in to the function, here is the code : browser.CallFunction($"document.querySelector('#{id}').outerHTML").Then(ret => { var sasdasd = ret; if(ret.Value != null) { htmlContent = (string)ret.Value; } }); – ShadowlessGT Mar 08 '23 at 16:15

1 Answers1

0

I Found a Solution guys just like this:

browser.EvalJS("document.documentElement.outerHTML").Then(res => Debug.Log("Document contents: " + res)).Done();