add support_phantompy.py

This commit is contained in:
emdee 2022-11-15 22:01:55 +00:00
parent 2686ab3db0
commit a06a1829d6
2 changed files with 9 additions and 22 deletions

View File

@ -126,6 +126,8 @@ from PyQt5.QtWidgets import QApplication
from PyQt5.QtPrintSupport import QPrinter
from PyQt5.QtWebEngineWidgets import QWebEnginePage
from support_phantompy import vsetup_logging
global LOG
import logging
import warnings

View File

@ -12,7 +12,7 @@ from PyQt5 import QtWidgets
from PyQt5.QtWidgets import (QProgressBar, QWidget, QVBoxLayout)
from phantompy import Render
from lookupdns import LookFor as Render
# from lookupdns import LookFor as Render
global LOG
import logging
@ -85,27 +85,12 @@ def iMain(largs, bgui=True):
url = largs[0]
outfile = largs[1]
jsfile = largs[2] if len(largs) > 2 else None
if os.path.exists(url):
with open(url, 'rt') as ofd:
elts = ofd.readlines()
random.shuffle(elts)
lelts = elts[:4]
else:
lelts = [url]
for i, elt in enumerate(lelts):
# run only starts the url loading
r = Render(app, do_print=False, do_save=True)
uri = elt.strip()
uri = url.strip()
r.run(uri, outfile, jsfile)
per = int(float(i)*100.0/2/len(lelts))
LOG.debug(f"{r.percent} {app.lstart} {per} {i}")
if len(lelts) == 1: break
for j in range(1, random.randint(30, 120)):
# google throttles too many links at a time
if widget:
widget.update(str(per))
app.processEvents()
time.sleep(1)
LOG.debug(f"{r.percent} {app.lstart}")
LOG.info(f"queued {len(app.lstart)} urls")
# run until app.exec() is finished (Qt window is closed)