{"id":15233855,"url":"https://github.com/answerdotai/playwrightnb","last_synced_at":"2025-09-21T01:33:26.002Z","repository":{"id":235934212,"uuid":"791565548","full_name":"AnswerDotAI/playwrightnb","owner":"AnswerDotAI","description":"Use sync mode Playwright interactively, inside a Jupyter notebook","archived":false,"fork":false,"pushed_at":"2025-04-02T23:09:32.000Z","size":392,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-09-18T04:58:41.659Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://answerdotai.github.io/playwrightnb/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AnswerDotAI.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-25T00:21:39.000Z","updated_at":"2025-06-26T18:01:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"b35f544c-fc5b-4b82-84d1-c78d8a859b1c","html_url":"https://github.com/AnswerDotAI/playwrightnb","commit_stats":{"total_commits":14,"total_committers":2,"mean_commits":7.0,"dds":0.0714285714285714,"last_synced_commit":"19e2f36ad8c1bebeb4b57c2accc794d72fdf9769"},"previous_names":["answerdotai/playwrightnb"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/AnswerDotAI/playwrightnb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Fplaywrightnb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Fplaywrightnb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Fplaywrightnb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Fplaywrightnb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AnswerDotAI","download_url":"https://codeload.github.com/AnswerDotAI/playwrightnb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Fplaywrightnb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276183679,"owners_count":25599223,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-20T02:00:10.207Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-29T06:08:31.310Z","updated_at":"2025-09-21T01:33:25.931Z","avatar_url":"https://github.com/AnswerDotAI.png","language":"Jupyter Notebook","readme":"# PlaywrightNB\n\n\n\u003c!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! --\u003e\n\n`PlaywrightNB` provides some little quality-of-life helpers for\ninteractive use of the wonderful\n[Playwright](https://playwright.dev/python/) library. It’s 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’s 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’s 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’t 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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanswerdotai%2Fplaywrightnb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanswerdotai%2Fplaywrightnb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanswerdotai%2Fplaywrightnb/lists"}