0

NOTE: THIS QUESTION IS FOR SWIFT 2, OS X, NOT IOS.

I need a way to programmatically get post-js processed source content (the final source content that is available in a browser's"view source" option).

When programmatically retrieving source content, it has placeholders for the JSON search results instead of the actual results that a browser's "view source" shows.

I'm able to get the page loaded, but don't know how to extract the source content of the loaded URL.

func loadAddressURL() {
    let url = "https://url/search"
    let URL = NSURL(string: url)!
    let request = NSURLRequest(URL: URL)
    webView.mainFrame.loadRequest(request)
}
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
dbconfession
  • 1,147
  • 2
  • 23
  • 36
  • Possible duplicate of [Is it possible to extract the source code of a URL loaded in webview?](http://stackoverflow.com/questions/37536453/is-it-possible-to-extract-the-source-code-of-a-url-loaded-in-webview) – Code Different Jun 23 '16 at 04:00

1 Answers1

0

Use the following code:

document.createTextNode( document.documentElement.outerHTML );

in an Action App Extension to access the URL and return the HTML:

Extension point                                 Typical app extension functionality

Action (iOS and macOS; UI and non-UI variants)  Manipulate or view content originating in a host app. 

References

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265