Add :debug-dump-page command.
This can probably be merged into :download later, when the mess is cleaned up.
This commit is contained in:
parent
52aca30342
commit
31892b437e
@ -1226,6 +1226,7 @@ These commands are mainly intended for debugging. They are hidden if qutebrowser
|
||||
|<<debug-cache-stats,debug-cache-stats>>|Print LRU cache stats.
|
||||
|<<debug-console,debug-console>>|Show the debugging console.
|
||||
|<<debug-crash,debug-crash>>|Crash for debugging purposes.
|
||||
|<<debug-dump-page,debug-dump-page>>|Dump the current page's content to a file.
|
||||
|<<debug-pyeval,debug-pyeval>>|Evaluate a python string and display the results as a web page.
|
||||
|<<debug-trace,debug-trace>>|Trace executed code via hunter.
|
||||
|<<debug-webaction,debug-webaction>>|Execute a webaction.
|
||||
@ -1251,6 +1252,18 @@ Crash for debugging purposes.
|
||||
==== positional arguments
|
||||
* +'typ'+: either 'exception' or 'segfault'.
|
||||
|
||||
[[debug-dump-page]]
|
||||
=== debug-dump-page
|
||||
Syntax: +:debug-dump-page [*--plain*] 'dest'+
|
||||
|
||||
Dump the current page's content to a file.
|
||||
|
||||
==== positional arguments
|
||||
* +'dest'+: Where to write the file to.
|
||||
|
||||
==== optional arguments
|
||||
* +*-p*+, +*--plain*+: Write plain text instead of HTML.
|
||||
|
||||
[[debug-pyeval]]
|
||||
=== debug-pyeval
|
||||
Syntax: +:debug-pyeval 's'+
|
||||
|
@ -1225,6 +1225,24 @@ class CommandDispatcher:
|
||||
tab.setHtml(highlighted, current_url)
|
||||
tab.viewing_source = True
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', scope='window',
|
||||
debug=True)
|
||||
def debug_dump_page(self, dest, plain=False):
|
||||
"""Dump the current page's content to a file.
|
||||
|
||||
Args:
|
||||
dest: Where to write the file to.
|
||||
plain: Write plain text instead of HTML.
|
||||
"""
|
||||
web_view = self._current_widget()
|
||||
mainframe = web_view.page().mainFrame()
|
||||
if plain:
|
||||
data = mainframe.toPlainText()
|
||||
else:
|
||||
data = mainframe.toHtml()
|
||||
with open(dest, 'w', encoding='utf-8') as f:
|
||||
f.write(data)
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', name='help',
|
||||
completion=[usertypes.Completion.helptopic],
|
||||
scope='window')
|
||||
|
Loading…
Reference in New Issue
Block a user