This repository was archived by the owner on Feb 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +58
-0
lines changed
Expand file tree Collapse file tree 4 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1+ source 'https://rubygems.org'
2+
3+ gem 'nokogiri' , '~> 1.10' , '>= 1.10.1'
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments