playwrightnb


Nameplaywrightnb JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/AnswerDotAI/playwrightnb
SummaryHelpers for using Playwright from notebooks and more
upload_time2024-09-12 16:45:25
maintainerNone
docs_urlNone
authorJeremy Howard
requires_python>=3.8
licenseApache Software License 2.0
keywords nbdev jupyter notebook python playwright
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PlaywrightNB


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

`PlaywrightNB` provides some little quality-of-life helpers for
interactive use of the wonderful
[Playwright](https://playwright.dev/python/) library. It’s likely to be
particularly of interest to folks using Jupyter.

## Install

    pip install playwrightnb

## Overview

``` python
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:

``` python
sh_url = 'https://help.dyalog.com/19.0/#UserGuide/Installation%20and%20Configuration/Shell%20Scripts.htm'
cts,iframes = read_page(sh_url)
```

Use [`h2md`](https://AnswerDotAI.github.io/playwrightnb/core.html#h2md)
to convert the HTML to markdown:

``` python
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`](https://AnswerDotAI.github.io/playwrightnb/core.html#url2md)
to read the page, find the selector, and convert to markdown. E.g, for
accessing Discord’s JS-rendered docs:

``` python
url = 'https://discord.com/developers/docs/interactions/application-commands'
sel = '.page-content-scrolling-container'
md = url2md(url, sel)
```

``` python
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`](https://AnswerDotAI.github.io/playwrightnb/core.html#get2md)
instead, which uses `httpx.get` instead of playwright.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/AnswerDotAI/playwrightnb",
    "name": "playwrightnb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "nbdev jupyter notebook python playwright",
    "author": "Jeremy Howard",
    "author_email": "info@fast.ai",
    "download_url": "https://files.pythonhosted.org/packages/52/52/2a2f8603afc4c3f19b808b9981a4c5ef7097d0af4a3611b72d304fd93271/playwrightnb-0.2.2.tar.gz",
    "platform": null,
    "description": "# PlaywrightNB\n\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n`PlaywrightNB` provides some little quality-of-life helpers for\ninteractive use of the wonderful\n[Playwright](https://playwright.dev/python/) library. It\u2019s likely to be\nparticularly of interest to folks using Jupyter.\n\n## Install\n\n    pip install playwrightnb\n\n## Overview\n\n``` python\nfrom playwrightnb import *\nfrom html.parser import HTMLParser\n```\n\n`playwrightnb` provide two main functions: `read_page_async(url)`, and\n`read_page(url)`. They are identical except the 1st is async.\n\nThey return a tuple of the main HTML page contents, and a dict mapping\niframe IDs to their HTML contents. They handle Javascript and other\ntrickiness largely automatically, however you can pass a `pause`\nparameter (in milliseconds) if you need to insert some manual waits. You\ncan also pass a `timeout` (also in milliseconds).\n\nFor instance, the Dyalog APL help information is provided inside an\niframe that\u2019s dynamically loaded by JS, but we are able to read it\ndirectly:\n\n``` python\nsh_url = 'https://help.dyalog.com/19.0/#UserGuide/Installation%20and%20Configuration/Shell%20Scripts.htm'\ncts,iframes = read_page(sh_url)\n```\n\nUse [`h2md`](https://AnswerDotAI.github.io/playwrightnb/core.html#h2md)\nto convert the HTML to markdown:\n\n``` python\nprint(h2md(iframes['topic'])[94:250])\n```\n\n    ## Shell Scripts\n\n    Shell scripts are typically executed from a terminal (or shell).\n\n    A script is executed by typing its name. User input is entered from the \n\nIn the case where you want to grab some particular element using a CSS\nselector, use\n[`url2md`](https://AnswerDotAI.github.io/playwrightnb/core.html#url2md)\nto read the page, find the selector, and convert to markdown. E.g, for\naccessing Discord\u2019s JS-rendered docs:\n\n``` python\nurl = 'https://discord.com/developers/docs/interactions/application-commands'\nsel = '.page-content-scrolling-container'\nmd = url2md(url, sel)\n```\n\n``` python\nprint(md[856:1215])\n```\n\n    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).\n\n    ## Application Command Object\n\n    ###### Application Command Naming\n\nIf you don\u2019t need JS-rendering or other fanciness, use\n[`get2md`](https://AnswerDotAI.github.io/playwrightnb/core.html#get2md)\ninstead, which uses `httpx.get` instead of playwright.\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "Helpers for using Playwright from notebooks and more",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/AnswerDotAI/playwrightnb"
    },
    "split_keywords": [
        "nbdev",
        "jupyter",
        "notebook",
        "python",
        "playwright"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3c237df9e7187d4699a8a3621019876b8e0f991f616b92da8a0bad7693e36120",
                "md5": "620288ded2bc8cebfda0b7993313d066",
                "sha256": "3dd67c281134d0ae775d6279921043693ad9af6244246b3126fa7f9494bc2ea6"
            },
            "downloads": -1,
            "filename": "playwrightnb-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "620288ded2bc8cebfda0b7993313d066",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5592,
            "upload_time": "2024-09-12T16:45:24",
            "upload_time_iso_8601": "2024-09-12T16:45:24.425038Z",
            "url": "https://files.pythonhosted.org/packages/3c/23/7df9e7187d4699a8a3621019876b8e0f991f616b92da8a0bad7693e36120/playwrightnb-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "52522a2f8603afc4c3f19b808b9981a4c5ef7097d0af4a3611b72d304fd93271",
                "md5": "b0fd300fa97566bbfa85a197cadca72d",
                "sha256": "d296ad94b0a7477d06fdcedb111fe5242dd9ff7363a289b7c0ca454464c28ec5"
            },
            "downloads": -1,
            "filename": "playwrightnb-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "b0fd300fa97566bbfa85a197cadca72d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5589,
            "upload_time": "2024-09-12T16:45:25",
            "upload_time_iso_8601": "2024-09-12T16:45:25.914840Z",
            "url": "https://files.pythonhosted.org/packages/52/52/2a2f8603afc4c3f19b808b9981a4c5ef7097d0af4a3611b72d304fd93271/playwrightnb-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-12 16:45:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AnswerDotAI",
    "github_project": "playwrightnb",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "playwrightnb"
}
        
Elapsed time: 1.21312s