• Stars
    star
    7
  • Rank 2,223,576 (Top 46 %)
  • Language
    Crystal
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a simple wrapper for crystal-xml

WARNING: This library is no longer maintained because something wonderful has come along. Try to enjoy: Lexbor.

hq.cr Build Status

a simple wrapper for crystal-xml and myhtml

  • gateway pattern : suppress errors until values are referenced
  • handy accessors : provide useful extractors and conversions

Installation

  • crystal: 0.23.x

Add this to your application's shard.yml:

dependencies:
  hq:
    github: maiha/hq.cr
    version: 0.2.3

xpath

require "hq"

node = Hq.parse("<html><body><div>82 users</div></body></html>")
node.xpath("/html/body/div").text # => "82 users"
node.xpath("/html/body/div").int  # => 82
node.xpath("/html/body/nav").int? # => nil
node.xpath("/html/body").path     # => "/html/body"
node.xpath("/html/div").text      # raise Hq::NotFound.new(key: "/html/div")

css

  • css selector
nodes = Hq::Css.parse <<-EOF
  <ul>
    <li>foo</li>
    <li>bar</li>
  </ul>
  EOF
nodes.css("li").map(&.text)  # => ["foo", "bar"]
  • node attributes
nodes = Hq::Css.parse <<-EOF
  <a href="https://github.com/crystal-lang/crystal" class="official">crystal</a>
  <a href="https://github.com/maiha/hq.cr">hq.cr</a>
  EOF
nodes.css("a").each do |a|
  p [a["href"], a["class"]?]
end

# => ["https://github.com/crystal-lang/crystal", "official"]
# => ["https://github.com/maiha/hq.cr", nil]

Roadmap

0.2.0

  • support css(tag)

0.3.0

  • support css(tag_with_class)
  • support Css::Node#attributes

0.4.0

  • support Hq.mapping like jq.cr

Contributing

  1. Fork it ( https://github.com/maiha/hq.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • maiha maiha - creator, maintainer

More Repositories

1

rcm.cr

Redis Cluster Manager in Crystal
Crystal
45
star
2

kafka.cr

kafka utilities written in crystal
Crystal
34
star
3

rocksdb.cr

RocksDB client for Crystal
Crystal
34
star
4

crystal-examples

This has been completely rewritten in 2019. The old implementation has moved to the alpha branch.
Crystal
31
star
5

crt.cr

Bindings for libncursesw and crt class
Crystal
28
star
6

try.cr

Try monad for crystal
Crystal
26
star
7

pcap.cr

Crystal bindings for libpcap
Crystal
24
star
8

crb

A cucumber console that offers cucumber world enviroment on irb
Ruby
20
star
9

xq.cr

Command-line XML processor inspired by `jq`
Crystal
17
star
10

redis-cluster-benchmark.cr

Benchmark utils for Redis Cluster
Crystal
16
star
11

pretty.cr

Something attentive, conservative and pretty stuff for Crystal
Crystal
16
star
12

jq.cr

thin JSON::Any wrapper to emulate jq for crystal
Crystal
16
star
13

must

a runtime specification tool
Ruby
15
star
14

grafana-redis.cr

Grefana Datasource for Redis storage
Crystal
15
star
15

gatling-amqp

Gatling AMQP support
Scala
15
star
16

typed

A Ruby library for Typed variables
Ruby
14
star
17

redis-cluster.cr

redis-cluster library for Crystal
Crystal
13
star
18

htpasswd

ActionPack plugin for authorizing users with HTTP basic/digest authentications
Ruby
12
star
19

memoized.cr

Time-based memoized library for Crystal
Crystal
11
star
20

tokyocabinet

unofficial repository for TokyoCabinet
C
11
star
21

pg-copy-ch

Simply copy the current PostgreSQL data to ClickHouse
Crystal
10
star
22

clickhouse-cluster-examples

Examples of the cluster topologies in ClickHouse
Makefile
10
star
23

facebook.cr

CLI for the Facebook Marketing API.
Crystal
9
star
24

ircbot

old fashioned irc bot
Ruby
9
star
25

rrr

Ruby programming with RR
Ruby
9
star
26

mod_cband

mod_cband Apache2 module
C
8
star
27

dsl_accessor

Ruby
8
star
28

ccp

A Ruby library for Composite Command Programming
Ruby
7
star
29

sexy_auto_complete

Rails plugin for better auto_complete, especially it gets along with ActiveScaffold nested forms
Ruby
7
star
30

comment-spec.cr

Comment driven spec builder for Crystal
Crystal
6
star
31

shard.cr

compile-time shard.yml reader for Crystal
Crystal
6
star
32

http-gate

Quite simple http port forwarder
Crystal
6
star
33

auto_nested_layouts

Use multiple nested layout files in Rails
Ruby
6
star
34

curl.cr

high level curl library for crystal
Crystal
6
star
35

open-uri-mapping

a wrapper to open-uri that offers filename mapping, which is useful for test
Ruby
5
star
36

mjs

A Ruby library that offers quite easy-to-use Ajax actions like RJS with jQuery
Ruby
5
star
37

css_parser

hpricot helper that scrapes html easily by parser class defined css selector
Ruby
5
star
38

protobuf-storage.cr

A handy local storage library for Protobuf
Crystal
5
star
39

rows_logger

ActiveRecord plugin for writing rows count information in query log
Ruby
5
star
40

cuke-utils

Goodies for cuke
Ruby
5
star
41

chawan

A cup for chasen that provides an easy to use for extracting Japanese
Ruby
5
star
42

rails_log

Rails log analyzer application with Ext-JS
Ruby
5
star
43

redis-tsv.cr

import and export data from Redis in TSV format
Crystal
5
star
44

request_id

Rails plugin that adds a new method (Controller#request_id) to distinguish requests
Ruby
4
star
45

ext

ActionPack plugin for using Ext-JS
Ruby
4
star
46

tdiary_google_calendar_plugin

A tdiary plugin that shows event list from google calendar
Ruby
4
star
47

unicode_japanese

Japanese charset converter especially for hankaku and zenkaku characters
Ruby
4
star
48

selenium-chrome.cr

A handy and thin wrapper for `selenium-webdriver-crystal`
Crystal
4
star
49

kafka-utils

Simple Kafka Utils in Scala
Scala
4
star
50

clickhouse.cr

ClickHouse client for Crystal
Crystal
4
star
51

mvc-benchmark-2010

A sample applications to bench MVC frameworks
4
star
52

merb_inspector

no needs to prepare views, scaffold and pagination. just inspect it
Ruby
4
star
53

scoped_access

restrict database access by using with_scope
Ruby
4
star
54

pon.cr

Maiha's private ORM for Crystal
Crystal
4
star
55

tokyotyrant

unofficial repository for TokyoTyrant
4
star
56

ohm-arfreaks

Ohm::Model extensions for AR freaks
Ruby
3
star
57

night-time

A ruby gem that treats over-midnight time easily
Ruby
3
star
58

sexy_actions

defining actions by block
Ruby
3
star
59

hash-path

path accessor to hierarchical hash
Ruby
3
star
60

http-mock

Real http server for stubbing and expectations in Scala
Scala
3
star
61

innodb-cluster-docker

a helper for running InnoDB Cluster on docker
Shell
3
star
62

named_options

Ruby
3
star
63

merb_background

a merb slice for background-fu
Ruby
3
star
64

2ch

local image storage application for 2ch
JavaScript
3
star
65

rack_format_response

A Rack middleware for automatically formatting response body
Ruby
3
star
66

opts.cr

a wrapper for OptionParser to provide default values and handy args
Crystal
3
star
67

acts_with_comma

Rails plugin that accepts numeric value with comma in AR#setter and text_field
Ruby
3
star
68

var.cr

`Object.var` macro for Crystal
Crystal
3
star
69

merb_rjs

Merb plugin that enables you to use 'page' object in your controllers like RJS of Rails
3
star
70

redisniffer

Sniff redis packets and summarize count of commands
Crystal
3
star
71

genspec

A Rails utils that automatically generates a rspec file for the latest action written in a log file
3
star
72

dm-ys

a DataMapper extension that uses html table as its schema and data powerfully like YunkerStar
Ruby
3
star
73

twitter-ads.cr

Twitter Ads API SDK for Crystal
Crystal
2
star
74

crystal-init.sh

a simple wrapper for crystal init command
Shell
2
star
75

crc16.cr

crc16 for Crystal
Crystal
2
star
76

james-bond

James is a bond framework for web development
Ruby
2
star
77

yak-farm

A farm view for Yak
2
star
78

lmdb.cr

Lmdb client for Crystal
Crystal
2
star
79

scalerity

Scalerity = Scala + Celerity
Scala
2
star
80

record_dumper

ActiveRecord plugin for printing record value to various formats
Ruby
2
star
81

hosts_access

Rails/Merb plugin that controls host access like hosts.allow
Ruby
2
star
82

web_api

Basic classes for general Web API
Ruby
2
star
83

toml-config.cr

TOML::Config class for handy use of crystal-toml
Crystal
2
star
84

tokyocabinet.cr

TokyoCabinet client for Crystal
Crystal
2
star
85

clickhouse-table

A standalone ClickHouse table manager that provides partial data updates
Crystal
2
star
86

optionize

method arguments utils
2
star
87

cmds.cr

Yet another CLI Builder library for Crystal
Crystal
2
star
88

base32.cr

Base32 Encoding for Crockford's Base32
Crystal
2
star
89

edd

Error driven development plugin for Rails
2
star
90

wildcard

A ruby library to expand wildcard string like shell command line
2
star
91

active_record_view

Ruby
2
star
92

active_seven

ActiveRecord plugin for 7th normal form
Ruby
2
star
93

include_for

Ruby
2
star
94

sandboxed_methods

Avoid conflicting method and variable names between modules
Ruby
2
star
95

akka-watch-child

study: to know whether a parent actor will watch its child automatically or not.
Scala
2
star
96

neo4j

Neo4j manager that provides many commands such as load,dump,touch,inspect,list
2
star
97

migration2

Yet another migartion library for ActiveRecord
Ruby
2
star
98

habto

ActiveRecord plugin for habtm utils
Ruby
2
star
99

active-scaffold.cr

ActiveScaffold for Amber on Crystal
CSS
2
star
100

traildb.cr

TrailDB bindings for Crystal
Crystal
1
star