https://github.com/borisbresciani/rails_parse_head
Parse head element (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head)
https://github.com/borisbresciani/rails_parse_head
html-head parse parsing
Last synced: about 1 year ago
JSON representation
Parse head element (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head)
- Host: GitHub
- URL: https://github.com/borisbresciani/rails_parse_head
- Owner: BorisBresciani
- License: mit
- Created: 2019-12-17T22:16:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-04-12T05:32:48.000Z (about 3 years ago)
- Last Synced: 2025-03-18T18:58:27.575Z (over 1 year ago)
- Topics: html-head, parse, parsing
- Language: Ruby
- Homepage:
- Size: 39.1 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# RailsParseHead
[](https://badge.fury.io/rb/rails_parse_head)
[](https://codeclimate.com/github/BorisBresciani/rails_parse_head/maintainability)
[](https://travis-ci.org/BorisBresciani/rails_parse_head)
[](https://hakiri.io/github/BorisBresciani/rails_parse_head/master)

[](https://coveralls.io/github/BorisBresciani/rails_parse_head?branch=master)
RailsParseHead is a simple Ruby library for parsing head element information from a website.
Learn more about the head element at:
- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head
- https://github.com/joshbuchea/HEAD
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'rails_parse_head'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install rails_parse_head
## Usage
### Parsing an URL
```ruby
rph = RailsParseHead.fetch('https://github.com')
rph.title # => "The world’s leading software development platform · GitHub"
rph.metas # => [{:charset=>"utf-8"}, {:name=>"viewport", :content=>"width=device-width"}]
rph.links # => [{:rel=>"dns-prefetch", :href=>"https://github.githubassets.com"}, {:rel=>"dns-prefetch", :href=>"https://avatars0.githubusercontent.com"}]
```
#### Custom header request
```ruby
rph = RailsParseHead.fetch('https://github.com', headers: { accept: 'application/json' })
```
See: https://github.com/httprb/http/wiki/Headers
### Parsing a HTML string
```ruby
rph = RailsParseHead.parse("")
rph.metas # => [{:charset=>"utf-8"}]
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/BorisBresciani/rails_parse_head. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
Everyone interacting in the RailsParseHead project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/BorisBresciani/rails_parse_head/blob/master/CODE_OF_CONDUCT.md).