0

I need to read a specific HTML of a div that is loaded in a webview

doc = web.stringByEvaluatingJavaScript(from: "document.body.innerHTML")!

With the above code I get the HTML in the webview and turn it into a string

Now I'm trying to get a particular div that HTML

<div id="status_load" name="status_load">DESLIGADO</div><p>Luz <a href="?pin=LIGADO"><button>Ligar</button></a>&nbsp;<a href="?pin=DESLIGADO"><button>Desligar</button></a></p>

I tried to do so, but do not return anything!

web.stringByEvaluatingJavaScript(from: "document.getElementById('status_load').value")!

Does anyone know how to do this?

Rene
  • 145
  • 1
  • 11
  • divs don't have values. `.value` is for form `` tags. – Marc B Oct 19 '16 at 18:57
  • of the same, does not return anything – Rene Oct 19 '16 at 18:59
  • I think what you need is an HTML parser. Take a look at this discussion for an overview of what is available: http://stackoverflow.com/questions/31080818/what-is-the-best-practice-to-parse-html-in-swift – Marcus Oct 19 '16 at 20:50

0 Answers0