ios - Load Single HTML Element in WKWebView -


i'm able html url , load in wkwebview, i'm wanting load single element html. in case, element aside, <aside class="col-sm-4 col-md-3 col-lg-3 sidebar">

my code getting of html.

func gethtmlstring() -> string? {          let urlstring = "https://kyfb.com/\(county)"          guard let countyurl = url(string: urlstring) else {             return nil         }          {             let htmlstring = try string(contentsof: countyurl, encoding: .isolatin1)             return htmlstring         } catch let error {             print("error: \(error)")             return nil         }     } 

the specific url i'm trying https://kyfb.com/jefferson. there aside there has i'm wanting show.

extracting element html code downloaded easy:

    guard let html = gethtml()         else { return }      let regex = try! nsregularexpression(pattern: "<aside class=\"col-sm-4 col-md-3 col-lg-3 sidebar\">([\\s\\s]*)</aside>")     let match = regex         .matches(in: html, range: nsrange(html.startindex..., in: html))         .map {             html.substring(with: range($0.range, in: html)!)     }      self.webview.loadhtmlstring(match.first!, baseurl: nil) 

the problem css/js won't captured. solution injecting javascript , hiding every element except <aside></aside>


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -