{"id":51232183,"url":"https://github.com/xcrap-dev/factory","last_synced_at":"2026-06-28T17:02:06.720Z","repository":{"id":299348266,"uuid":"1002729877","full_name":"xcrap-dev/factory","owner":"xcrap-dev","description":"Xcrap Factory is a set of utilities for dynamically creating instances of clients, extractors, and parsing models, making it easier to configure and extend scraping and parsing pipelines.","archived":false,"fork":false,"pushed_at":"2026-03-06T09:37:47.000Z","size":1097,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-12T14:52:33.031Z","etag":null,"topics":["factory","scraping","web","xcrap"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@xcrap/factory","language":"TypeScript","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/xcrap-dev.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-16T03:51:53.000Z","updated_at":"2026-02-27T20:49:25.000Z","dependencies_parsed_at":"2025-06-16T04:57:50.810Z","dependency_job_id":"d3d140bc-70bd-4312-9aa4-aafa414f96f2","html_url":"https://github.com/xcrap-dev/factory","commit_stats":null,"previous_names":["xcrap-cloud/factory","xcrap-dev/factory"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xcrap-dev/factory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Ffactory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Ffactory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Ffactory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Ffactory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xcrap-dev","download_url":"https://codeload.github.com/xcrap-dev/factory/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcrap-dev%2Ffactory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34896652,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"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":["factory","scraping","web","xcrap"],"created_at":"2026-06-28T17:02:05.764Z","updated_at":"2026-06-28T17:02:06.715Z","avatar_url":"https://github.com/xcrap-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🕷️ Xcrap Factory: Instantiate clients, parsing models, and extractors from configuration objects\n\nXcrap Factory is a set of utilities for dynamically creating instances of clients, extractors, and parsing models, making it easier to configure and extend scraping and parsing pipelines.\n\n## 📦 Installation\n\nInstallation is straightforward—just use your favorite dependency manager. Here’s an example using NPM:\n\n```cmd\nnpm i @xcrap/factory\n```\n\n## 🛠️ Features\n\n* **createClient**: Instantiates clients from a registry of allowed classes.\n* **createExtractor**: Creates extractor functions from configurable text and a registry of allowed extractors.\n* **createParsingModel**: Builds validated and nested parsing models with customizable extractors and types.\n\n## 🚀 Usage\n\n### 1. Creating a Client\n\n```typescript\nimport { GotScrapingClient } from \"@xcrap/got-scraping-client\"\nimport { AxiosClient } from \"@xcrap/axios-client\"\nimport { createClient } from \"@xcrap/factory\"\n\nconst config = {\n\tallowedClients: {\n\t\t\"got-scraping\": GotScrapingClient,\n\t\t\"axios\": AxiosClient \n\t}\n}\n\nconst client = createClient({\n\tconfig: config,\n\ttype: \"...\", // Client type\n\toptions: {...} // Client constructor options\n})\n```\n\n### 2. Creating an Extractor\n\n```typescript\nimport { extractInnerText, extractSrc, extractHref, extractAttribute } from \"@xcrap/parser\"\nimport { createExtractor } from \"@xcrap/factory\"\n\nconst config = {\n\tallowedExtractors: {\n\t\tinnerText: extractInnerText,\n\t\tsrc: extractSrc,\n\t\thref: extractHref,\n\t\tattribute: extractAttribute // extractAttribute(name: string) -\u003e Generates an extractor\n\t},\n\targumentSeparator: \":\" // Optional | Usage example -\u003e \"attribute:value\"\n}\n\nconst extractor = createExtractor({\n\textractorText: \"..\", // innerText, src, href, attribute:ATTRIBUTE_NAME...\n\tconfig: config\n})\n```\n\n### 3. Creating a Parsing Model\n\n```typescript\nimport { HtmlParsingModel, JsonParsingModel } from \"@xcrap/parser\"\nimport { createParsingModel } from \"@xcrap/factory\"\n\nconst config = {\n\tallowedExtractors: {...},\n\textractorArgumentSeparator: \"...\", // Optional\n\tallowedModels: {\n\t\thtml: HtmlParsingModel,\n\t\tjson: JsonParsingModel\n\t}\n}\n\nconst parsingModel = createParsingModel({\n\tconfig: config,\n\tmodel: {\n\t\ttype: \"html\", // Model type: html, json..\n\t\tmodel: {\n\t\t\ttitle: {\n\t\t\t\tquery: \"title\",\n\t\t\t\textractor: \"innerText\",\n\t\t\t},\n\t\t\tbodyData: { // Nested model\n\t\t\t\tquery: \"body\",\n\t\t\t\tnested: {\n\t\t\t\t\ttype: \"html\",\n\t\t\t\t\tmodel: {\n\t\t\t\t\t\theading: {\n\t\t\t\t\t\t\tquery: \"h1\",\n\t\t\t\t\t\t\textractor: \"innerText\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n})\n```\n\n## 🧪 Testing\n\nAutomated tests are located in `__tests__`. To run them:\n\n```bash\nnpm run test\n```\n\n## 🤝 Contributing\n\n* Want to contribute? Follow these steps:\n* Fork the repository.\n* Create a new branch (git checkout -b feature-new).\n* Commit your changes (git commit -m 'Add new feature').\n* Push to the branch (git push origin feature-new).\n* Open a Pull Request.\n\n## 📝 License\n\nThis project is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcrap-dev%2Ffactory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxcrap-dev%2Ffactory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcrap-dev%2Ffactory/lists"}