Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit e151f60

Browse files
author
Alexey Simakov
committed
Init
0 parents  commit e151f60

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM ruby:2.4.0
2+
3+
RUN apt-get update
4+
RUN apt-get install -y squashfs-tools bison
5+
6+
RUN curl -L http://enclose.io/rubyc/rubyc-linux-x64.gz | gunzip > rubyc
7+
RUN chmod +x rubyc && cp rubyc /usr/local/bin/
8+
9+
RUN mkdir -p /usr/src/app
10+
WORKDIR /usr/src/app
11+
12+
# Copy application files
13+
COPY ./ ./
14+
15+
RUN rubyc test.rb

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'nokogiri', '~> 1.10', '>= 1.10.1'

Gemfile.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
mini_portile2 (2.4.0)
5+
nokogiri (1.10.1)
6+
mini_portile2 (~> 2.4.0)
7+
8+
PLATFORMS
9+
ruby
10+
11+
DEPENDENCIES
12+
nokogiri (~> 1.10, >= 1.10.1)
13+
14+
BUNDLED WITH
15+
1.16.2

test.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'rubygems'
4+
require 'bundler/setup'
5+
6+
require 'nokogiri'
7+
require 'open-uri'
8+
9+
# Fetch and parse HTML document
10+
doc = Nokogiri::HTML(open('http://example.com'))
11+
12+
puts "### Search for nodes by css"
13+
doc.css('nav ul.menu li a', 'article h2').each do |link|
14+
puts link.content
15+
end
16+
17+
puts "### Search for nodes by xpath"
18+
doc.xpath('//nav//ul//li/a', '//article//h2').each do |link|
19+
puts link.content
20+
end
21+
22+
puts "### Or mix and match."
23+
doc.search('nav ul.menu li a', '//article//h2').each do |link|
24+
puts link.content
25+
end

0 commit comments

Comments
 (0)