Browser

public class Browser : NSObject, WKNavigationDelegate, WKScriptMessageHandler

The browser used to perform the web scraping.

This class encapsulates the webview and its delegates, providing an closure based API.

Properties

  • The webview itself

    Declaration

    Swift

    public private(set) var webView: WKWebView! { get }

WKNavigationDelegate

  • Tells the delegate that navigation is complete.

    Declaration

    Swift

    public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!)

    Parameters

    webView

    The web view that loaded the content.

    navigation

    The navigation object that finished.

  • Tells the delegate that an error occurred during the early navigation process.

    Declaration

    Swift

    public func webView(
        _ webView: WKWebView,
        didFailProvisionalNavigation navigation: WKNavigation!,
        withError error: Error
    )

    Parameters

    webView

    The web view that called the delegate method.

    navigation

    The navigation object for the operation. This object corresponds to a WKNavigation object that WebKit returned when the load operation began. You use it to track the progress of that operation.

    error

    The error that occurred.

  • Tells the delegate that an error occurred during navigation.

    Declaration

    Swift

    public func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error)

    Parameters

    webView

    The web view that reported the error.

    navigation

    The navigation object for the operation. This object corresponds to a WKNavigation object that WebKit returned when the load operation began. You use it to track the progress of that operation.

    error

    The error that occurred.

WKScriptMessageHandler

  • Tells the handler that a webpage sent a script message.

    Declaration

    Swift

    public func userContentController(
        _ userContentController: WKUserContentController,
        didReceive message: WKScriptMessage
    )

    Parameters

    userContentController

    The user content controller that delivered the message to your handler.

    message

    An object that contains the message details.