I tried to work around that by loading the page in a offscreen WKWebView, waiting for the delegate callback and then using the -evaluateJavascript:completionHandler method to fetch the html.
WKWebView has one major advantage: it saves cookies. This means that I only need to log in once and I don't need to display the webView for all following requests.
Problem: The -evaluateJavaScript:completionHandler method is block based and I can't get it to work (@omz @JonB do you have any idea what I'm doing wrong?)
@on_main_thread
def js_eval_completionHandler(_cmd, _obj_ptr, err_ptr):
print('Did call completionHandler')
def webView_didFinishNavigation_(_self, _cmd, _webView, _navigation):
webView = ObjcInstance(_webView)
snippet_content_load_block = ObjCBlock(js_eval_completionHandler, restype=None, argtypes=[c_void_p, c_void_p, c_void_p])
webView.evaluateJavaScript_completionHandler_('document.documentElement.outerHTML.toString()', snippet_content_load_block)
The js_eval_completionHandler gets never called