qwebkit

Parsing HTML with C++ (using Qt preferably)

只愿长相守 提交于 2020-02-23 04:10:28
问题 I'm trying to parse some HTML with C++ to extract all urls from the HTML (the urls can be inside the href and src attributes). I tried to use Webkit to do the heavy work for me but for some reason when I load a frame with HTML the generated document is all wrong (if I make Webkit get the page from the web the generated document is just fine but Webkit also downloads all images, styles, and scripts and I don't want that) Here is what I tried to do: frame->setHtml(HTML); QWebElement document =

How to follow a link in QWebKit?

这一生的挚爱 提交于 2020-01-11 02:34:23
问题 Having a DOM of the following html; <a href="?op=order"> <img class="img_button" src="picture.gif" onMouseOver="this.src='some.gif';" onMouseOut="this.src='some_other.gif';" alt="" border="0"> </a> how to follow a link (href) in QWebKit (specifically QWebPage). Please notice that it's an image that is linked. I can't do it (and I don't want to even if I could) by simulating a mouse click as I don't use QWebView thus I don't have the page rendered. 回答1: Assuming you have the link's QWebElement

QWebKit doesn't handle click and dblclick for Google Maps

耗尽温柔 提交于 2020-01-06 14:53:23
问题 I just copy/pasted this code from google maps API in a my index.html <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html { height: 100% } body { height: 100%; margin: 0; padding: 0 } #map_canvas { height: 100% } </style> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=MYKEY&sensor=false"> </script> <script type="text/javascript"> function initialize() { var mapOptions = { center: new

QtWebView — C++ — How to get javascript string returned from linkClicked event

随声附和 提交于 2020-01-06 07:25:35
问题 I have been unable to find a definitive answer to my problem. I currently have a QWebView control load an html file that is on my hard-drive, that implements a vector map with javascript actions. The html file loads a jvectormap US States Map. The click action on any state fires the onRegionClick action that is tied to the showCities function, which the event and code arguments are handled by the onRegionClick method implemented in the jquery-jvectormap.js file. The html file follows: <

Using QWebEngine to render an image

旧时模样 提交于 2020-01-01 09:15:22
问题 I'm looking to replace QWebKit with QWebEngine in my headless renderer. I initialise the page with load() and connect a slot to loadFinished() to generate the final .PNG image. This used to work fine with WebKit but fails with QWebEngine . Code is as follows... _webView = new QWebEngineView(); .... // Render the HTML to an image QPainter painter(&image); _webView->page()->view()->render(&painter); painter.end(); I receive the following errors : "Asking for share context for widget that does

How to read data from QNetworkReply being used by QWebPage?

随声附和 提交于 2019-12-28 13:56:09
问题 I use QWebPage to download a webpage as well as all its resources. At the same time I'd like to get hold on raw data being downloaded by Qt during this process. Doing this by reading data from QNetworkReply in void QNetworkAccessManager::finished(QNetworkReply * reply) signal is not a good solution as data could have been already read by QWebPage itself. This is because QNetworkReply is a sequential-access QIODevice, which means that once data is read from the object, it no longer kept by the

QWebView doesn't load any external resources if it loads a html-file from qresources

Deadly 提交于 2019-12-23 09:41:01
问题 As described in the title my problem is that qwebview doesn't load a html file correctly if it resides in my resources. It loads it perfectly if I load it from outside of the resources as normal local file. But this is not an option for me. I would like to bundle the file with the application. EDIT: By the way, I'm talkin' about external resources from the web. (e.g. http://host.org/somejavascript.js) Thanks for any help 回答1: Please take a look at the second parameter of void QWebView:

QWebEngineView modify web content before render

自闭症网瘾萝莉.ら 提交于 2019-12-22 01:29:50
问题 I have three questions about QWebengineView (Qt 5.7.0): How can I modify the web content (add extra html/javascript) during load (before render) How can I get events when javascript resource included in webpage is loading ( I want to modify them, too). I get html content by page()->toHtml then set it back by setHtml , but content rendered don't like original (seems to loss format) Thanks for help! 来源: https://stackoverflow.com/questions/38162751/qwebengineview-modify-web-content-before-render

How to get QWebKit to display image?

只愿长相守 提交于 2019-12-21 12:17:26
问题 Okay, I have a Qt executable in the same directory as a file logo.png . I call the following: QString msg("<html><body><img src='logo.png' /></body></html>"); webView->setHtml(msg); where webview is the QWebKit pointer However, when I execute the program, the image does not display. I am executing the program from the directory that the image is in... why won't it display? This is driving me nuts! 回答1: The logo.png may not be resolved properly if a appropriate baseUrl is not given. Here is an

PySide. JavaScript. Execute js an get result as a pure text or html

百般思念 提交于 2019-12-14 03:14:22
问题 Would like to get calendar data from page like http://www.dukascopy.com/swiss/english/marketwatch/calendars/eccalendar/ The data is dynamic and loads with js-applet - "DukascopyApplet" I tried to extract data this way: app = QApplication(sys.argv) web = QWebView() web.page().mainFrame().loadFinished.connect(print_content) web.load(QUrl("http://www.dukascopy.com/swiss/english/marketwatch/calendars/eccalendar/")) web.show() frame = web.page().mainFrame() print(frame.evaluateJavaScript(