Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

[[qanda:topic_unsolved]] Pyside2 toHtml()?

$
0
0
Do not try to save to text or download the page using js, this is a lost cause (for security reasons). One workaround: put the content of the page within the GET parameters of a form: document.getElementById('name_of_my_element').innerHTML = '<form action="#" method="get"><input type="hidden" name="param1" value="'+ encodeURIComponent(getResultsHTML()) +'">' +'<input type="submit" value="Submit"></form>'; I made a js function getResultsHTML() that calculates results, but it can be any text, even a document.getElementById('name_of_my_element').innerHTML of you whole page In my python code it's simple: from PySide2.QtWebEngineWidgets import QWebEngineView from PySide2 import QtCore def run(): # ... self.myview = QWebEngineView() path_html_file = os.path.abspath(path_html_file) url_tlx = QtCore.QUrl.fromLocalFile(path_html_file) self.myview .load(url_tlx) self.myview .show() self.myview.urlChanged.connect(self.callback_url_changed) # this will trigger when url is changed def callback_url_changed(self): print(myview.url().toString()) # > file:///index.html?param1=text%20forwared%20in%20get# # continue with with re and urllib.parse to extract and decode from the string until a solution comes out...

Viewing all articles
Browse latest Browse all 13965

Trending Articles