Compare commits
2 commits
1cb4e53cce
...
c6a7d839d9
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c6a7d839d9 | ||
![]() |
1d92e0ec65 |
6 changed files with 127 additions and 81 deletions
|
@ -13,4 +13,5 @@ try:
|
||||||
vsetup_logging(log_level, logfile='', stream=sys.stderr)
|
vsetup_logging(log_level, logfile='', stream=sys.stderr)
|
||||||
except: pass
|
except: pass
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
iMain(sys.argv[1:], bgui=False)
|
iMain(sys.argv[1:], bgui=False)
|
||||||
|
|
11
lookupdns.py
11
lookupdns.py
|
@ -1,9 +1,14 @@
|
||||||
#!/usr/local/bin/python3.sh
|
#!/usr/local/bin/python3.sh
|
||||||
# -*-mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*
|
# -*-mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*
|
||||||
|
|
||||||
# Looks for urls https://dns.google/resolve?
|
"""
|
||||||
# and parses them to extract a magic field.
|
Looks for urls https://dns.google/resolve?
|
||||||
# https://dns.google/resolve?name=domain.name&type=TXT&cd=true&do=true
|
https://dns.google/resolve?name=domain.name&type=TXT&cd=true&do=true
|
||||||
|
and parses them to extract a magic field.
|
||||||
|
|
||||||
|
A good example of how you can parse json embedded in HTML with phantomjs.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -130,8 +130,6 @@ from PyQt5.QtWidgets import QApplication
|
||||||
from PyQt5.QtPrintSupport import QPrinter
|
from PyQt5.QtPrintSupport import QPrinter
|
||||||
from PyQt5.QtWebEngineWidgets import QWebEnginePage
|
from PyQt5.QtWebEngineWidgets import QWebEnginePage
|
||||||
|
|
||||||
from support_phantompy import vsetup_logging
|
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
import warnings
|
import warnings
|
||||||
|
@ -230,6 +228,7 @@ class Render(QWebEnginePage):
|
||||||
self._exit(level)
|
self._exit(level)
|
||||||
|
|
||||||
def _loadFinished(self, result):
|
def _loadFinished(self, result):
|
||||||
|
# RenderProcessTerminationStatus ?
|
||||||
self.percent = 30
|
self.percent = 30
|
||||||
LOG.info(f"phantom.py: _loadFinished {result} {self.percent}")
|
LOG.info(f"phantom.py: _loadFinished {result} {self.percent}")
|
||||||
LOG.debug(f"phantom.py: Evaluating JS from {self.jsfile}")
|
LOG.debug(f"phantom.py: Evaluating JS from {self.jsfile}")
|
||||||
|
|
|
@ -13,6 +13,7 @@ from PyQt5.QtWidgets import (QProgressBar, QWidget, QVBoxLayout)
|
||||||
|
|
||||||
from phantompy import Render
|
from phantompy import Render
|
||||||
# from lookupdns import LookFor as Render
|
# from lookupdns import LookFor as Render
|
||||||
|
from support_phantompy import vsetup_logging, omain_argparser
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
|
@ -63,23 +64,20 @@ async def main(widget, app, ilen):
|
||||||
app.exit()
|
app.exit()
|
||||||
# raise asyncio.CancelledError
|
# raise asyncio.CancelledError
|
||||||
return
|
return
|
||||||
LOG.debug(f"{app.ldone} {perc} {seconds}")
|
LOG.debug(f"{app.ldone} {seconds}")
|
||||||
except asyncio.CancelledError as ex:
|
except asyncio.CancelledError as ex:
|
||||||
LOG.debug("Task cancelled")
|
LOG.debug("Task cancelled")
|
||||||
|
|
||||||
def iMain(largs):
|
def iMain(largs):
|
||||||
parser = oMainArgparser()
|
parser = omain_argparser()
|
||||||
oargs = parser.parse_args(lArgs)
|
oargs = parser.parse_args(largs)
|
||||||
bgui=oargs.show_gui
|
bgui=oargs.show_gui
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from support_phantompy import vsetup_logging
|
|
||||||
d = int(os.environ.get('DEBUG', 0))
|
d = int(os.environ.get('DEBUG', 0))
|
||||||
if d > 0:
|
if d > 0:
|
||||||
vsetup_logging(10, stream=sys.stderr)
|
oargs.log_level = 10
|
||||||
else:
|
vsetup_logging(oargs.log_level, logfile='', stream=sys.stderr)
|
||||||
vsetup_logging(oargs.log_level, stream=sys.stderr)
|
|
||||||
vsetup_logging(log_level, logfile='', stream=sys.stderr)
|
|
||||||
except: pass
|
except: pass
|
||||||
|
|
||||||
app = QtWidgets.QApplication([])
|
app = QtWidgets.QApplication([])
|
||||||
|
|
43
setup.py
Normal file
43
setup.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
__version__ = "0.1.0"
|
||||||
|
|
||||||
|
long_description = "\n\n".join([
|
||||||
|
open("README.md").read(),
|
||||||
|
])
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="pahntompy",
|
||||||
|
version=__version__,
|
||||||
|
description="""A simple replacement for phantomjs using PyQt""",
|
||||||
|
long_description=long_description,
|
||||||
|
author="Michael Franzl (originally) Goebel",
|
||||||
|
author_email='',
|
||||||
|
license="1clause BSD",
|
||||||
|
packages=['phantompy'],
|
||||||
|
# url="",
|
||||||
|
# These are for reference only, pip is not able to download packages
|
||||||
|
# from github because the archives do not include the project-name.
|
||||||
|
download_url="https://github.com/debops/yaml2rst/releases",
|
||||||
|
keywords=['JavaScript', 'phantomjs'],
|
||||||
|
python_requires=">=3.6",
|
||||||
|
# probably works on PyQt6 and PySide2 but untested
|
||||||
|
install_requires=['qasync', 'PyQt5'],
|
||||||
|
entry_points={
|
||||||
|
'console_scripts': [
|
||||||
|
'phantompy = phantompy.__main__:iMain',
|
||||||
|
]
|
||||||
|
},
|
||||||
|
classifiers=[
|
||||||
|
'Development Status :: 4 - Beta',
|
||||||
|
'Environment :: Console',
|
||||||
|
'Intended Audience :: Developers',
|
||||||
|
'Intended Audience :: Web Developers',
|
||||||
|
'Natural Language :: English',
|
||||||
|
'Operating System :: OS Independent',
|
||||||
|
'Programming Language :: Python :: 3',
|
||||||
|
'Topic :: Software Development :: Documentation',
|
||||||
|
],
|
||||||
|
)
|
|
@ -80,7 +80,7 @@ def vsetup_logging(log_level, logfile='', stream=sys.stdout):
|
||||||
'NOTSET': logging.NOTSET,
|
'NOTSET': logging.NOTSET,
|
||||||
}
|
}
|
||||||
|
|
||||||
def omain__argparser(_=None):
|
def omain_argparser(_=None):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from OpenSSL import SSL
|
from OpenSSL import SSL
|
||||||
|
@ -106,9 +106,9 @@ def omain__argparser(_=None):
|
||||||
help="Operate on the HTML file with javascript")
|
help="Operate on the HTML file with javascript")
|
||||||
parser.add_argument('--html_output', type=str, default='',
|
parser.add_argument('--html_output', type=str, default='',
|
||||||
help="Write loaded and javascripted result to a HTML file")
|
help="Write loaded and javascripted result to a HTML file")
|
||||||
parser.add_argument('--pdf_output', type=str, default=''),
|
parser.add_argument('--pdf_output', type=str, default='',
|
||||||
help="Write loaded and javascripted result to a PDF file")
|
help="Write loaded and javascripted result to a PDF file")
|
||||||
parser.add_argument('--show_gui', type=bool, store_action=True),
|
parser.add_argument('--show_gui', type=bool, default=False, store_action=True),
|
||||||
help="show a progress meter that doesn't work")
|
help="show a progress meter that doesn't work")
|
||||||
parser.add_argument('html_url', type=str, nargs='?',
|
parser.add_argument('html_url', type=str, nargs='?',
|
||||||
required=True,
|
required=True,
|
||||||
|
|
Loading…
Reference in a new issue