mirror of https://github.com/Phantop/dotfiles
bin: script to get page html after js render
This commit is contained in:
parent
47a7a77085
commit
1f431d5d00
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys
|
||||
|
||||
from PyQt6.QtCore import QUrl
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
from PyQt6.QtWebEngineWidgets import QWebEngineView
|
||||
|
||||
def save_html(html):
|
||||
if len(sys.argv) > 2 and sys.argv[2] == '-f':
|
||||
filename = sys.argv[3] if len(sys.argv) > 3 else "dump.html"
|
||||
with open(filename, 'w') as f:
|
||||
f.write(html)
|
||||
else:
|
||||
print(html)
|
||||
sys.exit()
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
wv = QWebEngineView()
|
||||
|
||||
wv.loadFinished.connect(lambda: wv.page().toHtml(save_html))
|
||||
wv.load(QUrl.fromUserInput(sys.argv[1]))
|
||||
app.exec()
|
Loading…
Reference in New Issue