qwebpage

How to tell QWebPage not to load specific type of resources?

随声附和 提交于 2019-11-26 15:26:34
问题 How to tell QWebPage not to load specific type of resources like js, css or png? 回答1: The solution is to extend QNetworkAccessManager class and override it's virtual method QNetworkAccessManager::createRequest In our implementation we check the path of the requested url and if it's the one we don't want to download we create and hand over an empty request instead of the real one. Below is a complete, working example. #include <QApplication> #include <QUrl> #include <QtWebKit/QWebPage>

How to know when a web page is loaded when using QtWebKit?

 ̄綄美尐妖づ 提交于 2019-11-26 13:08:31
问题 Both QWebFrame and QWebPage have void loadFinished(bool ok) signal which can be used to detect when a web page is completely loaded. The problem is when a web page has some content loaded asynchronously (ajax). How to know when the page is completely loaded in this case? 回答1: I haven't actually done this, but I think you may be able to achieve your solution using QNetworkAccessManager . You can get the QNetworkAccessManager from your QWebPage using the networkAccessManager() function.

Scrape multiple urls using QWebPage

懵懂的女人 提交于 2019-11-26 05:42:31
问题 I\'m using Qt\'s QWebPage to render a page that uses javascript to update its content dynamically - so a library that just downloads a static version of the page (such as urllib2) won\'t work. My problem is, when I render a second page, about 99% of the time the program just crashes. At other times, it will work three times before crashing. I\'ve also gotten a few segfaults, but it is all very random. My guess is the object I\'m using to render isn\'t getting deleted properly, so trying to