WKWebView无法从https://mobile.bet365.com加载整页

时间:2018-08-09 23:49:54

标签: wkwebview

print(html)之后,我得到了没有数据的清晰HTML。

import UIKit
import WebKit
class ViewController: UIViewController,WKNavigationDelegate{


    let webView = WKWebView()

    func webView(_ webView: WKWebView,
                 didFinish navigation: WKNavigation!) {
        print("loaded")
        webView.evaluateJavaScript("document.documentElement.innerHTML.toString()",
                                   completionHandler: { (html: Any?, error: Error?) in
                                    print(html)

        })

    }

    override func viewDidLoad() {
        super.viewDidLoad()
        let url = URL (string: "https://mobile.bet365.com")
        let request = URLRequest (url:url!)
        webView.frame = CGRect (x:0,y:0,width:300,height:300)
        webView.navigationDelegate = self

        webView.load(request)
        view.addSubview(webView)

    }
}

0 个答案:

没有答案