||2 weeks ago|
|.github/workflows||2 weeks ago|
|doc||2 weeks ago|
|phantompy||2 weeks ago|
|tests||2 weeks ago|
|.gitignore||2 weeks ago|
|LICENSE||2 weeks ago|
|Pipfile||2 weeks ago|
|README.md||2 weeks ago|
|appveyor.yml||2 weeks ago|
|setup.cfg||2 weeks ago|
|setup.py||2 weeks ago|
A simple replacement for phantomjs using PyQt.
This code is based on a brilliant idea of Michael Franzl that he wrote up in his blog:
- Generate a PDF screenshot of the web page after it is completely loaded.
- console.log's will be printed to stdout.
If you execute an external
way of knowing when that script has finished doing its work. For this
reason, the external script should execute at the end
console.log("__PHANTOM_PY_DONE__"); when done. This will trigger
the PDF generation or the file saving, after which phantompy will exit.
If you do not want to run any javascipt file, this trigger is provided
in the code by default.
It is important to remember that since you're just running WebKit, you can use everything that WebKit supports, including the usual JS client libraries, CSS, CSS @media types, etc.
Qt picks up proxies from the environment, so this will respect
http_proxy if set.
- PyQt5 (this should work with PySide2 and PyQt6 - let us know.)
- qasnyc for the
A standalone program is a little tricky as PyQt PyQt5.QtWebEngineWidgets' QWebEnginePage uses callbacks at each step of the way:
- loading the page =
- saving the page =
Render.toHtml and _html_callback
- printing the page =
The steps get chained by printing special messages to the Python
So it makes it hard if you want the standalone program to work without
a GUI, or in combination with another Qt program that is responsible
for the PyQt
app.exec and the exiting of the program.
We've decided to use the best of the shims that merge the Python
asyncio and Qt event loops:
qasyc. This is seen as
the successor to the sorta abandoned quamash.
The code is based on a
by Alex March who's excellent code helped me.
As this is my first use of
qasync I may have
introduced some errors and it may be improved on, but it works, and
it not a monolithic Qt program, so it can be used as a library.
The standalone program is
DEBUG=1 in the environment will give debugging messages
When I think of all the trouble people went to compiling and maintaining the tonnes of C++ code that went into phantomjs, I am amazed that it can be replaced with a couple of hundred lines of Python!