hyper_miner 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/hyper_miner.rb +33 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7a6574797cfd7c56f4f0c7611668079d47c4ccd1
|
4
|
+
data.tar.gz: 102a12cee84d9514c3d5d3f1b52020537cd61ea8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1a7ea0c1639908357885f3982ade637d51456b9f43665057c91366c7353e98929779ce9c75dc7fc260a48021a3bbc3f4c9365eec9d46aa7e76050e94e7a2580d
|
7
|
+
data.tar.gz: 9c3f63746d8edbe2ad3aa71b3e848c777f044e04df610caa526e79fe0632f8c38552480705daee95ab56cd7a370ccabb6c61ec106168b7dcb34ae08fe766a01e
|
data/lib/hyper_miner.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
class HyperMiner
|
6
|
+
|
7
|
+
def initialize(url, instructions)
|
8
|
+
@url = url
|
9
|
+
@instructions = YAML.load_file(instructions)
|
10
|
+
end
|
11
|
+
|
12
|
+
def mine
|
13
|
+
html = open(@url).read
|
14
|
+
|
15
|
+
parse(html)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def parse(html)
|
21
|
+
data = {}
|
22
|
+
|
23
|
+
@instructions.each do |instruction|
|
24
|
+
name = instruction[0]
|
25
|
+
selector = instruction[1]['selector']
|
26
|
+
|
27
|
+
data[name] = Nokogiri::HTML(html).css(selector).map(&:text)
|
28
|
+
end
|
29
|
+
|
30
|
+
data
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hyper_miner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Deyan Dobrinov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-02 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Simple web data miner written in Ruby.
|
14
|
+
email: deyan.dobrinov@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/hyper_miner.rb
|
20
|
+
homepage:
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.2.2
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Hyper miner
|
44
|
+
test_files: []
|