{"id":15713590,"url":"https://github.com/madeindjs/crystagiri","last_synced_at":"2025-04-14T22:51:22.794Z","repository":{"id":96108837,"uuid":"75745561","full_name":"madeindjs/Crystagiri","owner":"madeindjs","description":"An Html parser library for Crystal (like Nokogiri for Ruby)","archived":false,"fork":false,"pushed_at":"2020-05-01T17:29:09.000Z","size":78,"stargazers_count":135,"open_issues_count":2,"forks_count":9,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-09T01:36:58.967Z","etag":null,"topics":["crystal","html-parser-library"],"latest_commit_sha":null,"homepage":"https://madeindjs.github.io/Crystagiri/","language":"Crystal","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/madeindjs.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}},"created_at":"2016-12-06T15:41:15.000Z","updated_at":"2024-05-31T11:53:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"a6472425-b622-4d93-8e2e-d48f89175fe6","html_url":"https://github.com/madeindjs/Crystagiri","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madeindjs%2FCrystagiri","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madeindjs%2FCrystagiri/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madeindjs%2FCrystagiri/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madeindjs%2FCrystagiri/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/madeindjs","download_url":"https://codeload.github.com/madeindjs/Crystagiri/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248975299,"owners_count":21192199,"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":["crystal","html-parser-library"],"created_at":"2024-10-03T21:32:21.880Z","updated_at":"2025-04-14T22:51:22.776Z","avatar_url":"https://github.com/madeindjs.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Crystagiri\n\nAn HTML parser library for Crystal like the amazing [Nokogiri](https://github.com/sparklemotion/nokogiri) Ruby gem.\n\n\u003e I won't pretend that **Crystagiri** does much as **Nokogiri**. All help is welcome! :)\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  crystagiri:\n    github: madeindjs/crystagiri\n```\n\nand then run\n\n```bash\n$ shards install\n```\n\n## Usage\n\n```crystal\nrequire \"crystagiri\"\n```\n\nThen you can simply instantiate  a `Crystagiri::HTML` object from an HTML `String` like this\n\n```crystal\ndoc = Crystagiri::HTML.new \"\u003ch1\u003eCrystagiri is awesome!!\u003c/h1\u003e\"\n```\n\n... or directly load it from a Web URL or a pathname:\n\n```crystal\ndoc = Crystagiri::HTML.from_file \"README.md\"\ndoc = Crystagiri::HTML.from_url \"http://example.com/\"\n```\n\n\u003e Also you can specify `follow: true` flag if you want to follow redirect URL\n\nThen you can search all [`XML::Node`](https://crystal-lang.org/api/XML/Node.html)s from the `Crystagiri::HTML` instance. The tags found will be `Crystagiri::Tag` objects with the `.node` property:\n\n* CSS query\n\n```Crystal\nputs doc.css(\"li \u003e strong.title\") { |tag| puts tag.node}\n# =\u003e \u003cstrong class=\"title\"\u003e .. \u003c/strong\u003e\n# =\u003e \u003cstrong class=\"title\"\u003e .. \u003c/strong\u003e\n```\n\n\u003e **Known limitations**: Currently, you can't use CSS queries with complex search specifiers like `:nth-child`\n\n* HTML tag\n\n```Crystal\ndoc.where_tag(\"h2\") { |tag| puts tag.content }\n# =\u003e Development\n# =\u003e Contributing\n```\n\n* HTML id\n\n```Crystal\nputs doc.at_id(\"main-content\").tagname\n# =\u003e div\n```\n\n* HTML class attribute\n\n```Crystal\ndoc.where_class(\"summary\") { |tag| puts tag.node }\n# =\u003e \u003cdiv class=\"summary\"\u003e .. \u003c/div\u003e\n# =\u003e \u003cdiv class=\"summary\"\u003e .. \u003c/div\u003e\n# =\u003e \u003cdiv class=\"summary\"\u003e .. \u003c/div\u003e\n```\n\n## Benchmark\n\nI know you love benchmarks between **Ruby** \u0026 **Crystal**, so here's one:\n\n```ruby\nrequire \"nokogiri\"\nt1 = Time.now\ndoc = Nokogiri::HTML File.read(\"spec/fixture/HTML.html\")\n1..100000.times do\n  doc.at_css(\"h1\")\n  doc.css(\".step-title\"){ |tag| tag }\nend\nputs \"executed in #{Time.now - t1} milliseconds\"\n```\n\n\u003e executed in 00:00:11.10 seconds with Ruby 2.6.0 with RVM on old Mac\n\n```crystal\nrequire \"crystagiri\"\nt = Time.now\ndoc = Crystagiri::HTML.from_file \"./spec/fixture/HTML.html\"\n1..100000.times do\n  doc.at_css(\"h1\")\n  doc.css(\".step-title\") { |tag| tag }\nend\nputs \"executed in #{Time.now - t} milliseconds\"\n```\n\n\u003e executed in 00:00:03.09 seconds on Crystal 0.27.2 on LLVM 6.0.1 with release flag\n\nCrystagiri is more than **two time faster** than Nokogiri!!\n\n\n## Development\n\nClone this repository and navigate to it:\n\n```bash\n$ git clone https://github.com/madeindjs/crystagiri.git\n$ cd crystagiri\n```\n\nYou can generate all documentation with\n\n```bash\n$ crystal doc\n```\n\nAnd run **spec** tests to ensure everything works correctly\n\n```bash\n$ crystal spec\n```\n\n\n## Contributing\n\nDo you like this project? [here](https://github.com/madeindjs/Crystagiri/issues/) you can find\nsome issues to get started.\n\nContributing is simple:\n\n1. Fork it ( https://github.com/madeindjs/crystagiri/fork )\n2. Create your feature branch `git checkout -b my-new-feature`\n3. Commit your changes `git commit -am \"Add some feature\"`\n4. Push to the branch `git push origin my-new-feature`\n5. Create a new Pull Request\n\n## Contributors\n\nSee the [list on Github](https://github.com/madeindjs/Crystagiri/graphs/contributors)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadeindjs%2Fcrystagiri","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadeindjs%2Fcrystagiri","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadeindjs%2Fcrystagiri/lists"}