0

In a WKWebView, if I need webpage's title,I can get it via webView.title.

But when the first paragraph of webpage's contents is needed,there is no easy solution. Any advice and suggestions will be greatly appreciated,thanks.

Li Fumin
  • 1,383
  • 2
  • 15
  • 31

1 Answers1

1

If you control the HTML then you could use a query selector like:

document.querySelector("#content").innerText.split("\n")[0]

Note: You can inject javascript similar to this answer: Get HTML from WKWebview in Swift

Community
  • 1
  • 1
Onato
  • 9,916
  • 5
  • 46
  • 54