PlaywrightNB
PlaywrightNB provides some little quality-of-life helpers for
interactive use of the wonderful
Playwright library. It’s likely to be
particularly of interest to folks using Jupyter.
Install
pip install playwrightnb
Overview
from playwrightnb import *
from html.parser import HTMLParser
playwrightnb provide two main functions: read_page_async(url), and
read_page(url). They are identical except the 1st is async.
They return a tuple of the main HTML page contents, and a dict mapping
iframe IDs to their HTML contents. They handle Javascript and other
trickiness largely automatically, however you can pass a pause
parameter (in milliseconds) if you need to insert some manual waits. You
can also pass a timeout (also in milliseconds).
For instance, the Dyalog APL help information is provided inside an iframe that’s dynamically loaded by JS, but we are able to read it directly:
sh_url = 'https://help.dyalog.com/19.0/#UserGuide/Installation%20and%20Configuration/Shell%20Scripts.htm'
cts,iframes = read_page(sh_url)
Use h2md
to convert the HTML to markdown:
print(h2md(iframes['topic'])[94:250])
## Shell Scripts
Shell scripts are typically executed from a terminal (or shell).
A script is executed by typing its name. User input is entered from the
In the case where you want to grab some particular element using a CSS
selector, use
url2md
to read the page, find the selector, and convert to markdown. E.g, for
accessing Discord’s JS-rendered docs:
url = 'https://discord.com/developers/docs/interactions/application-commands'
sel = '.page-content-scrolling-container'
md = url2md(url, sel)
print(md[856:1215])
Application commands are native ways to interact with apps in the Discord client. There are 3 types of commands accessible in different interfaces: the chat input, a message's context menu (top-right menu or right-clicking in a message), and a user's context menu (right-clicking on a user).
## Application Command Object
###### Application Command Naming
If you don’t need JS-rendering or other fanciness, use
get2md
instead, which uses httpx.get instead of playwright.
Metadata
Release files for playwrightnb 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| playwrightnb-0.2.2.tar.gz | 5.6 kB | Without provenance | Details for playwrightnb-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| playwrightnb-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for playwrightnb-0.2.2-py3-none-any.whl |
Total release size: 11.2 kB
Release files / playwrightnb-0.2.2.tar.gz
| Download URL | playwrightnb-0.2.2.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d296ad94b0a7477d06fdcedb111fe5242dd9ff7363a289b7c0ca454464c28ec5
|
|
BLAKE2b-256 checksum How to use checksums |
52522a2f8603afc4c3f19b808b9981a4c5ef7097d0af4a3611b72d304fd93271
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.8
|
Release files / playwrightnb-0.2.2-py3-none-any.whl
| Download URL | playwrightnb-0.2.2-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3dd67c281134d0ae775d6279921043693ad9af6244246b3126fa7f9494bc2ea6
|
|
BLAKE2b-256 checksum How to use checksums |
3c237df9e7187d4699a8a3621019876b8e0f991f616b92da8a0bad7693e36120
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.8
|
Security for playwrightnb 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.