1
0
Fork 0
mirror of https://github.com/Phantop/dotfiles synced 2024-11-17 12:22:57 +00:00
dotfiles/bin/qtcurl

24 lines
622 B
Python
Executable file

#!/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()