Disable subframes (iframes) loaded in PhantomJs / QtWebKit

Is there a way to disable subframe loading in phantomJs or even QtWebKit / webkit in general? I have no problem with an array of bits with source code, if necessary. I do web manipulation, but I do not need the contents of the iframe, it only slows down the loading time.

I know that this can be done in Mozilla, for example.

webSetup->SetProperty(nsIWebBrowserSetup::SETUP_ALLOW_SUBFRAMES,PR_TRUE);

But so far I have not found anything in QtWebKit for this.

maybe there is a way to use onResourceRequested to block only requests on iframes?

+4
source share
1 answer

It works:

// load only the main page, no iframes
page.onLoadStarted = function() {
        page.navigationLocked = true;
};

, .

, :

var req_count = 0;
page.onResourceRequested = function(requestData, networkRequest) {
        if (req_count++ > 0) {
                networkRequest.abort();
        }
}

. :

http://phantomjs.org/api/webpage/handler/on-resource-requested.html http://newspaint.wordpress.com/2013/04/03/adblock-for-phantomjs/

+4

Source: https://habr.com/ru/post/1530955/


All Articles