{"id":13524960,"url":"https://github.com/ozanmakes/wring","last_synced_at":"2026-02-14T05:09:25.720Z","repository":{"id":57399801,"uuid":"52641449","full_name":"ozanmakes/wring","owner":"ozanmakes","description":"Extract content from webpages using CSS Selectors, XPath, and JS expressions","archived":false,"fork":false,"pushed_at":"2016-02-28T11:05:42.000Z","size":264,"stargazers_count":457,"open_issues_count":0,"forks_count":15,"subscribers_count":19,"default_branch":"master","last_synced_at":"2026-01-25T21:36:40.658Z","etag":null,"topics":["cheerio","phantomjs","xpath"],"latest_commit_sha":null,"homepage":"","language":"PureScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ozanmakes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-27T00:20:09.000Z","updated_at":"2025-10-27T19:05:48.000Z","dependencies_parsed_at":"2022-09-26T17:01:13.654Z","dependency_job_id":null,"html_url":"https://github.com/ozanmakes/wring","commit_stats":null,"previous_names":["ozanmakes/wring","osener/wring"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ozanmakes/wring","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozanmakes%2Fwring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozanmakes%2Fwring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozanmakes%2Fwring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozanmakes%2Fwring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ozanmakes","download_url":"https://codeload.github.com/ozanmakes/wring/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozanmakes%2Fwring/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29437371,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T03:34:37.767Z","status":"ssl_error","status_checked_at":"2026-02-14T03:34:09.092Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cheerio","phantomjs","xpath"],"created_at":"2024-08-01T06:01:14.949Z","updated_at":"2026-02-14T05:09:25.697Z","avatar_url":"https://github.com/ozanmakes.png","language":"PureScript","funding_links":[],"categories":["Command Line","PureScript"],"sub_categories":["Like jq"],"readme":"![](resources/media/img1.png)\n\n# ![](resources/media/img2.png) wring\n\n## Installation\nYou can install wring using [npm](https://www.npmjs.com/package/wring/tutorial):\n\n```sh\n$ npm install --global wring\n```\n\nWring utilizes [PhantomJS](http://phantomjs.org/) for some of its commands. To\nuse these, install it using your system package manager by running something\nlike `brew install phantomjs` on OS X, or `apt-get install phantomjs` on Ubuntu. You can\nmake sure it's on your `PATH` by running `phantomjs -v`.\n\nAlternatively, you can install a version which automatically downloads PhantomJS\nbinaries for your system:\n\n```sh\n$ npm install --global wring-with-phantomjs\n```\n\n## Usage\n\n#### `wring text`\n\nHere is a simple example which prints contents of the matching element (uses\n[Cheerio](https://github.com/cheeriojs/cheerio) under the hood):\n\n```sh\n$ wring text 'https://www.google.com/finance/converter?a=1\u0026from=EUR\u0026to=USD' '#currency_converter_result'\n1 EUR = 1.0940 USD\n\n# You can use the first letter of command as a shortcut\n$ wring t http://randomfunfacts.com i\nNo president of the United States was an only child.\n\n```\n\nYou can also use jQuery specific selectors such as `:contains()`:\n\n```sh\n$ wring t 'https://en.wikipedia.org/wiki/List_of_songs_recorded_by_Taylor_Swift' 'tr:contains(\"The Hunger Games\") th:first-child'\n\"Eyes Open\"\n\"Safe \u0026 Sound\"\n```\n\n####  `wring html`\n\nPrints `outerHTML`of matching elements. Here is an example, this time using an\nXPath expression:\n\n```sh\n$ wring html \"http://news.ycombinator.com\" \"//td[@class='title']/a[starts-with(@href,'http')]\"\n\u003ca href=\"http://eftimov.net/postgresql-indexes-first-principles\"\u003ePostgreSQL Indexes: First principles\u003c/a\u003e\n\u003ca href=\"http://inference-review.com/article/doing-mathematics-differently\"\u003eDoing Mathematics Differently\u003c/a\u003e\n\u003ca href=\"https://blog.chartmogul.com/api-based-saas/\"\u003eThe rise of the API-based SaaS\u003c/a\u003e\n\u003ca href=\"https://github.com/tallesl/Rich-Hickey-fanclub\"\u003eRich Hickey Fanclub\u003c/a\u003e\n...\n```\n\n####  Accepted inputs\n\nFirst argument of a command specifies its input, which can be a URL, path to a\nfile, HTML string, or `-` to read the page source from `stdin`:\n\n```sh\n# read from file\n$ curl 'http://www.purescript.org/' \u003e page.html\n$ wring t page.html '.intro h2'\nPureScript is a small strongly typed programming language that compiles to JavaScript.\n\n# read from string\n$ wring text '\u003cdiv class=\"foo\"\u003eHello\u003c/div\u003e' '.foo'\nHello\n\n# read from stdin\n$ curl -s 'http://www.merriam-webster.com/word-of-the-day' | wring text - '.word-and-pronunciation h1'\nkeelhaul\n```\n\n#### Using with PhantomJS\n\nPrefixing a command with `phantomjs` or `p` will run it using jQuery inside a\nreal web browser context. You can use this if you are having compatibility\nproblems with the commands above, but the real utility comes from being able to\nscrape dynamically generated content:\n\n```sh\n$ wring p t '\u003ctitle\u003eFoo\u003c/title\u003e \u003cscript\u003edocument.title = \"Bar\";\u003c/script\u003e' 'title'\nBar\n\n# compare it to the non-phantomjs invocation below\n$ wring t '\u003ctitle\u003eFoo\u003c/title\u003e \u003cscript\u003edocument.title = \"Bar\";\u003c/script\u003e' 'title'\nFoo\n\n```\n#### `wring eval`\n\nLets you evaluate JavaScript inside any page. Calling `wring('str')` will write\nto terminal. You can pass any number of .js file paths, URLs, and JS expressions\nas script arguments and they will get executed in given order:\n\n```sh\n$ wring eval 'http://ipfs.io' 'wring(document.title)'\nIPFS is a new peer-to-peer hypermedia protocol.\n\n# you can load and use third party libraries:\n$ wring e 'http://ipfs.io' 'http://cdn.jsdelivr.net/lodash/4.5.1/lodash.js' 'wring(_.kebabCase(document.title))'\nipfs-is-a-new-peer-to-peer-hypermedia-protocol\n```\n\n#### Self contained scripts\n\nYou can also use a trick to make self contained scripts.\n\nHere is a contrived example which loads Hacker News homepage, loads lodash,\nsorts posts by their score, and prints the top 5:\n\n```js\n#!/bin/sh\n\":\" //; exec wring eval \"https://news.ycombinator.com\" \"https://cdn.jsdelivr.net/lodash/4.5.1/lodash.js\" \"$0\"\n\nvar posts = _.map(\n  document.querySelectorAll(\".votelinks + .title \u003e a\"),\n  function(el) {\n    return el.textContent + \"\\n\" + el.href;\n  })\n\nvar scores = _.map(\n  document.querySelectorAll(\".score\"),\n  function (el) {\n    return parseInt(el.textContent, 10);\n  })\n\n_(posts)\n  .zipWith(scores, function (text, score) {\n    return { text: text, score: score };\n  })\n  .orderBy(\"score\", \"desc\")\n  .take(5)\n  .forEach(function (item) {\n    wring(item.text + \"\\n\");\n  })\n```\n\n```sh\n# after saving the source above to `wring_hn.js` you can run it like this\n$ chmod +x wring_hn.js\n$ ./wring_hn.js\nRaspberry Pi 3 Model B confirmed, with onboard BT LE and WiFi\nhttps://apps.fcc.gov/oetcf/eas/reports/...\n\nAfter fifteen years of downtime, the MetaFilter gopher server is back\nhttp://metatalk.metafilter.com/24019/...\n...\n```\n\n#### `wring shot`\n\nLast command to cover is `wring shot`, which renders a screenshot of first\nmatching element and saves it to a file:\n\n```sh\n$ wring shot 'https://www.google.com/finance?q=GOOG' '#price-panel' goog.png\nwring: Saved to goog.png\n```\nResulting `goog.png` will contain something like this:\n\n![GOOG](resources/media/goog.png)\n\n## Development\n```sh\n# Install Node.js dependencies:\n$ npm install\n\n# Install PureScript dependencies:\n$ bower install\n\n# Build `wring.js` and `phantom-main.js`:\n$ npm run build\n\n# Run tests:\n$ npm test\n\n# Compile \u0026 run using Pulp (https://github.com/bodil/pulp):\n$ pulp run text '\u003cb\u003efoo\u003c/b\u003e' 'b'\n```\n\n## License\n\n[MIT](https://github.com/osener/wring/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozanmakes%2Fwring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fozanmakes%2Fwring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozanmakes%2Fwring/lists"}