horsefield 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/horsefield.gemspec +1 -0
- data/lib/horsefield/scraper.rb +5 -1
- data/lib/horsefield/version.rb +1 -1
- data/spec/scraper_spec.rb +11 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 909d1fbaae07e72abcbfc56411f56eb13cdf3fb6
|
4
|
+
data.tar.gz: ad10de7bd9e695deac3b849be8aa643208253b44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d84f4e592ca0380e20515e7b1f8ea43c66931443c9ede76b89ac0ba6061bb3bc4ddeabb6774fc8147a1bc271d4756b50c532a09e7d38714c4d9b21c54b40500
|
7
|
+
data.tar.gz: e06816739c97b086416c7ee544506203d5607d85dd4c497b63886c501d065cc01f308e64499ea90f64ef23a333e4e4396a10f7501cb3c5d221479c49b75cda1e
|
data/horsefield.gemspec
CHANGED
data/lib/horsefield/scraper.rb
CHANGED
@@ -31,7 +31,11 @@ module Horsefield
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def html
|
34
|
-
|
34
|
+
if browser.is_a? Mechanize
|
35
|
+
@html || browser.get(@url).content
|
36
|
+
elsif browser.is_a? Watir::Browser
|
37
|
+
@html || browser.goto(@url); browser.html
|
38
|
+
end
|
35
39
|
end
|
36
40
|
|
37
41
|
def browser
|
data/lib/horsefield/version.rb
CHANGED
data/spec/scraper_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'horsefield/scraper'
|
3
|
+
require 'watir-webdriver'
|
3
4
|
|
4
5
|
describe Horsefield::Scraper do
|
5
6
|
describe 'with HTML' do
|
@@ -29,5 +30,15 @@ describe Horsefield::Scraper do
|
|
29
30
|
|
30
31
|
result[:job][:missing].should be_nil
|
31
32
|
end
|
33
|
+
|
34
|
+
it 'works with Watir' do
|
35
|
+
browser = Watir::Browser.new :phantomjs
|
36
|
+
|
37
|
+
result = Horsefield::Scraper.new(browser).scrape 'https://github.com/apa512' do
|
38
|
+
one :email, 'a.email'
|
39
|
+
end
|
40
|
+
|
41
|
+
p result
|
42
|
+
end
|
32
43
|
end
|
33
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: horsefield
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Strömberg
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 1.12.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: watir-webdriver
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: It's a scraper
|
112
126
|
email:
|
113
127
|
- erik.stromberg@gmail.com
|