diff --git a/bin/qtcurl b/bin/qtcurl index 5a822fa..f17faae 100755 --- a/bin/qtcurl +++ b/bin/qtcurl @@ -2,8 +2,10 @@ import sys from PyQt6.QtCore import QUrl -from PyQt6.QtWidgets import QApplication +from PyQt6.QtNetwork import QNetworkCookie +from PyQt6.QtWebEngineCore import QWebEngineProfile, QWebEngineCookieStore from PyQt6.QtWebEngineWidgets import QWebEngineView +from PyQt6.QtWidgets import QApplication def save_html(html): if len(sys.argv) > 2 and sys.argv[2] == '-f': @@ -15,8 +17,16 @@ def save_html(html): sys.exit() if __name__ == '__main__': + url = QUrl.fromUserInput(sys.argv[1]) + app = QApplication(sys.argv) - wv = QWebEngineView() + 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) wv.loadFinished.connect(lambda: wv.page().toHtml(save_html)) wv.load(QUrl.fromUserInput(sys.argv[1])) diff --git a/bin/shub b/bin/shub index 04e23b1..37bffce 100755 --- a/bin/shub +++ b/bin/shub @@ -15,15 +15,17 @@ for i in $chaps while true set page (qtcurl $i) if test -z "$page" - continue + echo "Invalid url: $i" + exit end - if test (echo $page | pup title text{}) = "Just a moment...\n" + if test (echo $page | pup title text{}) = "Just a moment..." open $i echo "Solve captcha in browser, then press enter." read - else - break + sleep 5 + continue end + break end set num (echo $i | rev | cut -d/ -f2 | rev) set ch_title (echo $page | pup title text{})