{"id":15107660,"url":"https://github.com/astares/pharo-chrome","last_synced_at":"2025-10-23T02:31:24.257Z","repository":{"id":78113750,"uuid":"91627513","full_name":"astares/Pharo-Chrome","owner":"astares","description":"Pharo support for Google Chrome","archived":false,"fork":false,"pushed_at":"2023-01-22T10:52:26.000Z","size":227,"stargazers_count":22,"open_issues_count":6,"forks_count":9,"subscribers_count":10,"default_branch":"main","last_synced_at":"2024-10-09T13:21:41.190Z","etag":null,"topics":["pharo"],"latest_commit_sha":null,"homepage":null,"language":"Smalltalk","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/astares.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-05-17T23:04:31.000Z","updated_at":"2023-03-11T08:03:30.000Z","dependencies_parsed_at":"2023-02-25T02:45:39.558Z","dependency_job_id":null,"html_url":"https://github.com/astares/Pharo-Chrome","commit_stats":{"total_commits":119,"total_committers":4,"mean_commits":29.75,"dds":0.4117647058823529,"last_synced_commit":"8270054f27f71041d88bad0c5bb6dc92101091b4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astares%2FPharo-Chrome","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astares%2FPharo-Chrome/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astares%2FPharo-Chrome/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astares%2FPharo-Chrome/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/astares","download_url":"https://codeload.github.com/astares/Pharo-Chrome/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219868429,"owners_count":16555761,"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","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":["pharo"],"created_at":"2024-09-25T21:40:47.994Z","updated_at":"2025-10-23T02:31:23.957Z","avatar_url":"https://github.com/astares.png","language":"Smalltalk","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pharo-Chrome\n\nPharo-Chrome provides a simple API for Google Chrome's DevTools protocol (https://chromedevtools.github.io/devtools-protocol/).\n\n[![Pharo version](https://img.shields.io/badge/Pharo-9.0-%23aac9ff.svg)](https://pharo.org/download)\n[![Pharo 10](https://img.shields.io/badge/Pharo-10-%23aac9ff.svg)](https://pharo.org/download)\n[![Pharo 11](https://img.shields.io/badge/Pharo-11-%23aac9ff.svg)](https://pharo.org/download)\n\n## Installation via Script\n\nFirst load [Pharo-OS-Windows](https://github.com/astares/Pharo-OS-Windows) if you are on Windows or [OSSubprocess](https://github.com/pharo-contributions/OSSubprocess) for Linux and Mac (see below). Then load:\n\n```Smalltalk\nMetacello new \n\trepository: 'github://astares/Pharo-Chrome:main/src';\n\tbaseline: 'Chrome';\n\tload\n```\n\n\nThe are three main public classes in the package:\n\n* GoogleChrome is the interface to the Chrome Browser\n* ChromeTabPage is the interface to a single tab / page in the browser\n* ChromeNode is a single DOM node within a page, with a similar interface to Soup\n\nA ZnEasy like interface is provided for retrieving pages:\n\n```smalltalk\nGoogleChrome get: 'http://pharo.org'\n```\n\nAn example of more detailed operations are available in `GoogleChrome class\u003e\u003eexampleNavigation`.\n\n## Features\n\n* A ZnEasy like feature for retrieving pages: #get:\n* Extraction of tabular data (html tables): #extractTables, #tableData\n* Screenshot capture: #captureScreenshot\n* Headless mode\n\n## Installation\n\nUnix platforms (Linux \u0026 MacOS) require OSProcess or OSSubprocess to be installed prior to loading Pharo-Chrome.  To load OSSubprocess in 32 bit images:\n\n```smalltalk\nMetacello new\n \tbaseline: 'OSSubprocess';\n \trepository: 'github://pharo-contributions/OSSubprocess:v1.3.0/repository';\n\tload.\n```\n\n\nOn Windows the OSWindows package is required:\n\n```smalltalk\nMetacello new \n\trepository: 'github://astares/Pharo-OS-Windows/src';\n\tbaseline: 'OSWindows' ;\n\tload\n```\n\nOnce the platform dependent packages have been loaded, load the main Pharo-Chrome package:\n\n```smalltalk\nMetacello new\n\tbaseline: 'Chrome';\n\trepository: 'github://astares/Pharo-Chrome:main/src';\n\tload.\n```\n\nTo keep the original Monticello idea of having #stable and #development versions, Pharo-Chrome is mostly using the GitFlow workflow:\n\n* The `master` branch is #stable\n* The `development` branch is #development\n\n\n## A Short Demo\n\n### Stock price retrieval\n\nAs a demonstration of Pharo-Chrome, we'll retrieve some stock prices from the Australian ASX S\u0026P 200 stock index:\n\n```smalltalk\nrootNode := GoogleChrome get: 'https://finance.yahoo.com/quote/%5EAXJO/history?p=%5EAXJO'\n```\n\nThe messages I use most for navigating the DOM are:\n\n\u003cdl\u003e\n  \u003cdt\u003e#children\u003c/dt\u003e\n  \u003cdd\u003eAnswer an array of the child nodes\u003c/dd\u003e\n  \u003cdt\u003e#parent\u003c/dt\u003e\n  \u003cdd\u003eAnswer the parent node of the receiver\u003c/dd\u003e\n  \u003cdt\u003e#findAllTags:\u003c/dt\u003e\n  \u003cdd\u003eFind all tags matching the supplied criteria (see below).\u003c/dd\u003e\n  \u003cdt\u003e#findAllStrings:\u003c/dt\u003e\n  \u003cdd\u003eFind all strings matching the supplied criteria.\u003c/dd\u003e\n  \u003cdt\u003e#allSelect:\u003c/dt\u003e\n  \u003cdd\u003eAnswer all nodes matching the supplied criteria.\u003c/dd\u003e\n\u003c/dl\u003e\n\nBoth #findAllTags: and #findAllStrings: can take a string, a collection or a boolean as the parameter.  E.g. to find the h1 and h2 headings:\n\n```smalltalk\nheadings := rootNode findAllTags: #('h1' 'h2').\n```\n\nMore interesting is extracting all the data from a table, e.g. historical prices:\n\n```smalltalk\ntables := rootNode extractTables.\n```\n\nAt the time of writing, two tables were returned.  The larger table is the one we're interested in.  Most of the rows will be actual data, smaller rows typically contain comments, so we'll make the data uniform by simply rejecting smaller rows.  It can be nicely inspected using:\n\n```\nhistoricalData := (tables sorted: #size ascending) last.\ndataFrame := DataFrame fromRows: (historicalData select: [ :each | each size = 7 ]).\ndataFrame asStringTable.\n\n\"\n     |  1             2         3         4         5         6            7       \n-----+-----------------------------------------------------------------------------\n1    |  Date          Open      High      Low       Close*    Adj Close**  Volume  \n2    |  Nov 14, 2017  6,021.80  6,021.80  5,957.10  5,966.00  5,966.00     -       \n3    |  Nov 13, 2017  6,029.40  6,029.40  6,010.70  6,021.80  6,021.80     -       \n4    |  Nov 10, 2017  6,049.40  6,049.40  6,020.70  6,029.40  6,029.40     -       \netc.\n\"\n```\n\nNote that the example above assumes that DataFrame has been installed in the image:\n\n```smalltalk\nMetacello new\n  baseline: 'DataFrame';\n  repository: 'github://PolyMathOrg/DataFrame';\n  load.\n```\n\n### pharo.org screenshot\n\nTo retrieve a png image of the pharo.org front page in headless mode:\n\n```smalltalk\n| browser page image |\n\nbrowser := GoogleChrome new.\nbrowser headless: true.\nbrowser open.\npage := browser firstTab.\npage get: 'http://pharo.org'.\nimage := page captureScreenshot.\nbrowser closeAndExit.\nimage\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastares%2Fpharo-chrome","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastares%2Fpharo-chrome","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastares%2Fpharo-chrome/lists"}