{"id":18609705,"url":"https://github.com/unlight/nightmare-xpath","last_synced_at":"2025-06-15T13:34:50.692Z","repository":{"id":29048844,"uuid":"32576512","full_name":"unlight/nightmare-xpath","owner":"unlight","description":"Nightmare plugin to select nodes by xpath expression.","archived":false,"fork":false,"pushed_at":"2020-09-25T19:29:01.000Z","size":17,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T05:41:36.429Z","etag":null,"topics":["nightmare","nightmare-plugin","nightmare-xpath"],"latest_commit_sha":null,"homepage":"","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/unlight.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2015-03-20T10:05:37.000Z","updated_at":"2023-02-12T03:17:04.000Z","dependencies_parsed_at":"2022-08-22T04:10:52.660Z","dependency_job_id":null,"html_url":"https://github.com/unlight/nightmare-xpath","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unlight%2Fnightmare-xpath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unlight%2Fnightmare-xpath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unlight%2Fnightmare-xpath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unlight%2Fnightmare-xpath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unlight","download_url":"https://codeload.github.com/unlight/nightmare-xpath/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248155253,"owners_count":21056591,"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":["nightmare","nightmare-plugin","nightmare-xpath"],"created_at":"2024-11-07T03:07:03.138Z","updated_at":"2025-04-10T22:31:39.118Z","avatar_url":"https://github.com/unlight.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nightmare-xpath\n\nNightmare plugin to select nodes by xpath expression.\n\n## INSTALL\n\nThis will install plugin `nightmare-xpath` for Nightmare 3.X:\n\n```sh\nnpm install --save-dev nightmare-xpath\n```\n\n**Note:** If you are looking for plugin for Nightmare 1.X, then use:\n\n```sh\nnpm install nightmare-xpath@1\n```\n\n## USAGE\n\n```js\nconst Nightmare = require('nightmare');\nrequire('nightmare-xpath')(Nightmare);\n\nconst links = await Nightmare()\n    .goto('http://example.com/')\n    .xpath('//a[@href]', function (node) {\n        // We cannot return DOM element to nodejs,\n        // we must return serializable object or primitive.\n        // If function is omitted, node.toString() will be used.\n        return node.href;\n    })\n    .then();\n\nconsole.log(links); // ['https://www.iana.org/domains/example']\n```\n\n## API\n\n`xpath(selector: string, handler?: (Node: node) =\u003e any): Array\u003cany\u003e`\n\n#### selector\n\nType: `string`\n\nXPath expression.\n\n#### handler\n\nType: `function`  \nOptional: Yes  \nSignature: `(Node: node) =\u003e any`\n\nThis function be called on each result of `XPathResult`.\nWe cannot return DOM element to nodejs,\nwe must return serializable object or primitive.\nIf function is omitted, node.toString() will be used.\n\n## RESOURCES\n\n-   https://developer.mozilla.org/ru/docs/Web/API/Document/evaluate\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funlight%2Fnightmare-xpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funlight%2Fnightmare-xpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funlight%2Fnightmare-xpath/lists"}