{"id":26930225,"url":"https://github.com/dial-once/node-dom-extractor","last_synced_at":"2025-04-02T06:17:33.750Z","repository":{"id":24095310,"uuid":"27482687","full_name":"dial-once/node-dom-extractor","owner":"dial-once","description":"A node package to extract DOM from a remote HTML page","archived":false,"fork":false,"pushed_at":"2018-11-30T08:42:13.000Z","size":52,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-21T14:17:57.772Z","etag":null,"topics":["dom-extractor","extract","extract-dom","javascript","nodejs","selector"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/dial-once.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":"2014-12-03T10:55:47.000Z","updated_at":"2024-05-15T01:19:46.000Z","dependencies_parsed_at":"2022-07-27T04:32:17.173Z","dependency_job_id":null,"html_url":"https://github.com/dial-once/node-dom-extractor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dial-once%2Fnode-dom-extractor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dial-once%2Fnode-dom-extractor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dial-once%2Fnode-dom-extractor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dial-once%2Fnode-dom-extractor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dial-once","download_url":"https://codeload.github.com/dial-once/node-dom-extractor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246763899,"owners_count":20829800,"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":["dom-extractor","extract","extract-dom","javascript","nodejs","selector"],"created_at":"2025-04-02T06:17:33.144Z","updated_at":"2025-04-02T06:17:33.737Z","avatar_url":"https://github.com/dial-once.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"node-dom-extractor\n==================\n\n[![Pipeline Status](https://gitlab.com/dial-once/node-dom-extractor/badges/master/pipeline.svg)](https://gitlab.com/dial-once/node-dom-extractor/commits/master)\n[![Sonar](http://proxy.dialonce.net/sonar/api/badges/gate?key=node-dom-extractor)](http://sonar.dialonce.net/dashboard?id=node-dom-extractor)\n[![Sonar](http://proxy.dialonce.net/sonar/api/badges/measure?key=node-dom-extractor\u0026metric=ncloc)](http://sonar.dialonce.net/dashboard?id=node-dom-extractor)\n[![Sonar](http://proxy.dialonce.net/sonar/api/badges/measure?key=node-dom-extractor\u0026metric=coverage)](http://sonar.dialonce.net/dashboard?id=node-dom-extractor)\n[![Sonar](http://proxy.dialonce.net/sonar/api/badges/measure?key=node-dom-extractor\u0026metric=code_smells)](http://proxy.dialonce.net/sonar/api/badges/measure?key=node-dom-extractor\u0026metric=coverage)\n[![Sonar](http://proxy.dialonce.net/sonar/api/badges/measure?key=node-dom-extractor\u0026metric=bugs)](http://sonar.dialonce.net/dashboard?id=node-dom-extractor)\n[![Sonar](http://proxy.dialonce.net/sonar/api/badges/measure?key=node-dom-extractor\u0026metric=sqale_debt_ratio)](http://sonar.dialonce.net/dashboard?id=node-dom-extractor)\n\nA node package used to extract a DOM element from a remote page or a string, using selectors. Based on jsdom for fetching and parsing, and juice for inlining css.\n\n### Install\n\n    npm install dom-extractor\n\n### Extract DOM from a remote URL\n```js\nvar extractor = require('dom-extractor');\nextractor.fetch(\"http://github.com/\", \"div.header\", function(data){\n\t//data contains the extracted HTML with css inlined, here the github header\n});\n```\n\n### Extract DOM from a string\n```js\nvar extractor = require('dom-extractor');\nextractor.fetch(\"\u003cdiv class='a'\u003eHello\u003c/div\u003e\u003cdiv class='b'\u003eWorld\u003c/div\u003e!\", \".a\", function(data){\n\t//should contains the div with class a\n});\n```\n\n#### Note about # selector\nWhen you use # as a selector, the browser do not send the data since it is a keyword for anchoring things in page, browser side.\nTo use it anyway, use |sharp| as the selector.\n\n#### Using options\nYou can use options as the second parameter. List of current options are:\n\n```js\n{\n\tselector: String, //set the selector for extraction default is body\n\tinnerText: Boolean, //get text only from extraction, no html or css default is false\n\tinlineCss: Boolean //Put style in style attributes of extracted dom default is true\n}\n```\n\nExample, using div.header selector and getting text only from result:\n```js\nvar extractor = require('dom-extractor');\nextractor.fetch(\"http://github.com/\", { selector: \"div.header\", innerText: true }, function(data){\n\t//data contains the extracted HTML with css inlined, here the github header\n});\n```\n\n### Use it as a middleware (Connect)\n```js\napp.use('/proxy', extractor.middleware());\n```\n\n### Running tests\n```\nnpm install\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdial-once%2Fnode-dom-extractor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdial-once%2Fnode-dom-extractor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdial-once%2Fnode-dom-extractor/lists"}