2024-01-31 15:51:59 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from PyQt6.QtCore import QUrl
|
2025-03-28 21:18:52 +00:00
|
|
|
from PyQt6.QtNetwork import QNetworkCookie
|
|
|
|
from PyQt6.QtWebEngineCore import QWebEngineProfile, QWebEngineCookieStore
|
2024-01-31 15:51:59 +00:00
|
|
|
from PyQt6.QtWebEngineWidgets import QWebEngineView
|
2025-03-28 21:18:52 +00:00
|
|
|
from PyQt6.QtWidgets import QApplication
|
2024-01-31 15:51:59 +00:00
|
|
|
|
|
|
|
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__':
|
2025-03-28 21:18:52 +00:00
|
|
|
url = QUrl.fromUserInput(sys.argv[1])
|
|
|
|
|
2024-01-31 15:51:59 +00:00
|
|
|
app = QApplication(sys.argv)
|
2025-03-28 21:18:52 +00:00
|
|
|
profile = QWebEngineProfile()
|
|
|
|
cookiestore = profile.cookieStore()
|
|
|
|
cookies = ['toc_show=999']
|
|
|
|
for i in cookies:
|
|
|
|
cookie = QNetworkCookie.parseCookies(i.encode('utf-8'))[0]
|
|
|
|
cookiestore.setCookie(cookie, url)
|
|
|
|
wv = QWebEngineView(profile)
|
2024-01-31 15:51:59 +00:00
|
|
|
|
|
|
|
wv.loadFinished.connect(lambda: wv.page().toHtml(save_html))
|
|
|
|
wv.load(QUrl.fromUserInput(sys.argv[1]))
|
|
|
|
app.exec()
|