mirror of
https://github.com/Phantop/dotfiles
synced 2025-12-08 12:58:18 +00:00
bin: adjust qtcurl and shub for full works
This commit is contained in:
parent
ba3f91e1ca
commit
befa249a5b
14
bin/qtcurl
14
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]))
|
||||
|
|
|
|||
10
bin/shub
10
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{})
|
||||
|
|
|
|||
Loading…
Reference in a new issue