myhtml
Version, currently 0.2847 versions
- 1.5.9latestApr 15, 2025
- 1.5.8not indexedApr 15, 2025
- 1.5.7not indexedApr 15, 2025
- 1.5.6not indexedApr 15, 2025
- 1.5.5not indexedApr 15, 2025
- 1.5.4not indexedApr 15, 2025
- 1.5.3not indexedApr 15, 2025
- 1.5.2not indexedApr 15, 2025
- 1.5.1not indexedApr 15, 2025
- 1.5.0not indexedApr 15, 2025
- 1.4.2not indexedApr 15, 2025
- 1.4.1not indexedApr 15, 2025
- 1.4.0not indexedApr 15, 2025
- 1.3.0not indexedApr 15, 2025
- 1.2.0not indexedApr 15, 2025
- 1.1.0not indexedApr 15, 2025
- 1.0.0not indexedApr 15, 2025
- 0.30not indexedApr 15, 2025
- 0.29not indexedApr 15, 2025
- 0.28not indexedApr 15, 2025
- 0.27not indexedApr 15, 2025
- 0.26not indexedApr 15, 2025
- 0.25not indexedApr 15, 2025
- 0.24not indexedApr 15, 2025
- 0.23not indexedApr 15, 2025
- 0.22not indexedApr 15, 2025
- 0.21not indexedApr 15, 2025
- 0.20not indexedApr 15, 2025
- 0.19not indexedApr 15, 2025
- 0.18not indexedApr 15, 2025
- 0.17not indexedApr 15, 2025
- 0.16.1not indexedApr 15, 2025
- 0.16not indexedApr 15, 2025
- 0.15not indexedApr 15, 2025
- 0.14not indexedApr 15, 2025
- 0.13.1not indexedApr 15, 2025
- 0.12not indexedApr 15, 2025
- 0.11not indexedApr 15, 2025
- 0.10.2not indexedApr 15, 2025
- 0.10.1not indexedApr 15, 2025
- 0.10not indexedApr 15, 2025
- 0.9not indexedApr 15, 2025
- 0.8not indexedApr 15, 2025
- 0.7not indexedApr 15, 2025
- 0.6not indexedApr 15, 2025
- 0.5not indexedApr 15, 2025
- v.0.13not indexedApr 15, 2025
github.com/kostya/myhtml
Fast HTML5 Parser with css selectors for Crystal language
157 stars
4 dependents
License: MIT
Nothing has been indexed for 0.28 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
myhtml:
github: kostya/myhtml
version: ~> 0.28Then run:
shards installshard.yml
No shard.yml has been indexed for 0.28. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
# MyHTML
[](https://github.com/kostya/myhtml/actions/workflows/ci.yml?query=branch%3Amaster+event%3Apush)
Fast HTML5 Parser (Crystal binding for awesome lexborisov's [myhtml](https://github.com/lexborisov/myhtml) and [Modest](https://github.com/lexborisov/Modest)). This shard used in production to parse millions of pages per day, very stable and fast.
## WARNING: original libraries (myhtml and Modest) not maintained since july 2020, i recommend switch to successor parser: [Lexbor](https://github.com/kostya/lexbor).
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
myhtml:
github: kostya/myhtml
```
And run `shards install`
## Usage example
```crystal
require "myhtml"
html = <<-HTML
<html>
<body>
<div id="t1" class="red">
<a href="/#">O_o</a>
</div>
<div id="t2"></div>
</body>
</html>
HTML
myhtml = Myhtml::Parser.new(html)
myhtml.nodes(:div).each do |node|
id = node.attribute_by("id")
if first_link = node.scope.nodes(:a).first?
href = first_link.attribute_by("href")
link_text = first_link.inner_text
puts "div with id #{id} have link [#{link_text}](#{href})"
else
puts "div with id #{id} have no links"
end
end
# Output:
# div with id t1 have link [O_o](/#)
# div with id t2 have no links
```
## Css selectors example
```crystal
require "myhtml"
html = <<-HTML
<html>
<body>
<table id="t1">
<tr><td>Hello</td></tr>
</table>
<table id="t2">
<tr><td>123</td><td>other</td></tr>
<tr><td>foo</td><td>columns</td></tr>
<tr><td>bar</td><td>are</td></tr>
<tr><td>xyz</td><td>ignored</td></tr>
</table>
</body>
</html>
HTML
myhtml = Myhtml::Parser.new(html)
p myhtml.css("#t2 tr td:first-child").map(&.inner_text).to_a
# => ["123", "foo", "bar", "xyz"]
p myhtml.css("#t2 tr td:first-child").map(&.to_html).to_a
# => ["<td>123</td>", "<td>foo</td>", "<td>bar</td>", "<td>xyz</td>"]
```
## More Examples
[examples](https://github.com/kostya/myhtml/tree/master/examples)
## Development Setup:
```shell
git clone https://github.com/kostya/myhtml.git
cd myhtml
make
crystal spec
```
## Benchmark
Parse 1000 times google page(600Kb), and 1000 times css select. [myhtml-program](https://github.com/kostya/myhtml/tree/master/bench/test-myhtml.cr), [crystagiri-program](https://github.com/kostya/myhtml/tree/master/bench/test-libxml.cr), [nokogiri-program](https://github.com/kostya/myhtml/tree/master/bench/test-libxml.rb)
| Lang | Shard | Lib | Parse time, s | Css time, s | Memory, MiB |
| -------- | ---------- | --------------- | ------------- | ----------- | ----------- |
| Crystal | lexbor | lexbor | 2.54 | 0.099 | 7.8 |
| Crystal | myhtml | myhtml(+modest) | 3.17 | 0.16 | 8.4 |
| Ruby 2.7 | Nokogiri | libxml2 | 9.19 | 10.76 | 139.8 |
| Crystal | Crystagiri | libxml2 | 11.27 | - | 25.0 |
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.28- Tagged
- Apr 15, 2025
- Commit
63022506f6c0- Indexed
- not yet
Dependents
Repository
github.com/kostya/myhtml
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 47