browsed 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +24 -22
- data/README.md +3 -3
- data/bin/browse +5 -9
- data/browsed.gemspec +6 -6
- data/lib/browsed/chrome.rb +7 -1
- data/lib/browsed/client.rb +10 -3
- data/lib/browsed/configuration.rb +4 -4
- data/lib/browsed/poltergeist.rb +1 -1
- data/lib/browsed/version.rb +1 -1
- metadata +15 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 567bb6800134cd99a989a974f961778d88c275e295c3b66e1e8890d5543caac1
|
4
|
+
data.tar.gz: 72d12642345e43922330e9b46f5400759873ef546aa84684bb5c990eb0a75456
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dff5ca6dc9fd9a055c6fcd7e3c96d9644ab071d03136df5cd26068338db33b2ec8ee4ce2e9119d4314cf4854bc2b55401c9f6210c6243e9b5150ae3992fa95b
|
7
|
+
data.tar.gz: f295827ad9b5acb1b1e1f8707f96d83f3e07a36e7acbf0000b4b042bcc98082e12412bac998eb87882dfdad90ecb2ed515901e254b8deb65fa92331edbd946a5
|
data/Gemfile.lock
CHANGED
@@ -1,50 +1,52 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
browsed (0.2.
|
4
|
+
browsed (0.2.1)
|
5
5
|
agents
|
6
|
-
capybara (~> 3.
|
6
|
+
capybara (~> 3.15)
|
7
7
|
poltergeist (~> 1.18, >= 1.18.1)
|
8
|
-
selenium-webdriver (~> 3.
|
8
|
+
selenium-webdriver (~> 3.141)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
addressable (2.
|
13
|
+
addressable (2.6.0)
|
14
14
|
public_suffix (>= 2.0.2, < 4.0)
|
15
|
-
agents (0.1.
|
16
|
-
capybara (3.
|
15
|
+
agents (0.1.4)
|
16
|
+
capybara (3.15.0)
|
17
17
|
addressable
|
18
18
|
mini_mime (>= 0.1.3)
|
19
19
|
nokogiri (~> 1.8)
|
20
20
|
rack (>= 1.6.0)
|
21
21
|
rack-test (>= 0.6.3)
|
22
|
-
|
22
|
+
regexp_parser (~> 1.2)
|
23
|
+
xpath (~> 3.2)
|
23
24
|
childprocess (0.9.0)
|
24
25
|
ffi (~> 1.0, >= 1.0.11)
|
25
26
|
cliver (0.3.2)
|
26
27
|
coderay (1.1.2)
|
27
28
|
diff-lcs (1.3)
|
28
|
-
ffi (1.
|
29
|
+
ffi (1.10.0)
|
29
30
|
launchy (2.4.3)
|
30
31
|
addressable (~> 2.3)
|
31
|
-
method_source (0.9.
|
32
|
+
method_source (0.9.2)
|
32
33
|
mini_mime (1.0.1)
|
33
|
-
mini_portile2 (2.
|
34
|
-
nokogiri (1.
|
35
|
-
mini_portile2 (~> 2.
|
34
|
+
mini_portile2 (2.4.0)
|
35
|
+
nokogiri (1.10.2)
|
36
|
+
mini_portile2 (~> 2.4.0)
|
36
37
|
poltergeist (1.18.1)
|
37
38
|
capybara (>= 2.1, < 4)
|
38
39
|
cliver (~> 0.3.1)
|
39
40
|
websocket-driver (>= 0.2.0)
|
40
|
-
pry (0.
|
41
|
+
pry (0.12.2)
|
41
42
|
coderay (~> 1.1.0)
|
42
43
|
method_source (~> 0.9.0)
|
43
44
|
public_suffix (3.0.3)
|
44
|
-
rack (2.0.
|
45
|
+
rack (2.0.6)
|
45
46
|
rack-test (1.1.0)
|
46
47
|
rack (>= 1.0, < 3)
|
47
|
-
rake (
|
48
|
+
rake (12.3.2)
|
49
|
+
regexp_parser (1.3.0)
|
48
50
|
rspec (3.8.0)
|
49
51
|
rspec-core (~> 3.8.0)
|
50
52
|
rspec-expectations (~> 3.8.0)
|
@@ -59,13 +61,13 @@ GEM
|
|
59
61
|
rspec-support (~> 3.8.0)
|
60
62
|
rspec-support (3.8.0)
|
61
63
|
rubyzip (1.2.2)
|
62
|
-
selenium-webdriver (3.
|
64
|
+
selenium-webdriver (3.141.0)
|
63
65
|
childprocess (~> 0.5)
|
64
66
|
rubyzip (~> 1.2, >= 1.2.2)
|
65
67
|
websocket-driver (0.7.0)
|
66
68
|
websocket-extensions (>= 0.1.0)
|
67
69
|
websocket-extensions (0.1.3)
|
68
|
-
xpath (3.
|
70
|
+
xpath (3.2.0)
|
69
71
|
nokogiri (~> 1.8)
|
70
72
|
|
71
73
|
PLATFORMS
|
@@ -73,11 +75,11 @@ PLATFORMS
|
|
73
75
|
|
74
76
|
DEPENDENCIES
|
75
77
|
browsed!
|
76
|
-
bundler (~> 1
|
78
|
+
bundler (~> 2.0.1)
|
77
79
|
launchy (~> 2.4, >= 2.4.3)
|
78
|
-
pry (~> 0.
|
79
|
-
rake (~>
|
80
|
-
rspec (~> 3.0)
|
80
|
+
pry (~> 0.12.2)
|
81
|
+
rake (~> 12.3.2)
|
82
|
+
rspec (~> 3.8.0)
|
81
83
|
|
82
84
|
BUNDLED WITH
|
83
|
-
|
85
|
+
2.0.1
|
data/README.md
CHANGED
@@ -21,10 +21,10 @@ Or install it yourself as:
|
|
21
21
|
## Usage
|
22
22
|
|
23
23
|
```ruby
|
24
|
-
# driver can be :poltergeist (PhantomJS) or :selenium/:selenium_chrome (Firefox/Chrome)
|
25
|
-
# browser can be: :phantomjs, :firefox, :
|
24
|
+
# driver can be :poltergeist (PhantomJS) or :selenium/:selenium_chrome/:selenium_chrome_headless (Firefox/Chrome)
|
25
|
+
# browser can be: :phantomjs, :chrome, :chrome_headless, :firefox, :firefox_headless
|
26
26
|
# device can be :desktop, :phone (iphone/android), :tablet (ipad/android), :iphone, :ipad, :android_phone, :android_tablet
|
27
|
-
client = Browsed::Client.new(driver: :
|
27
|
+
client = Browsed::Client.new(driver: :selenium_chrome, browser: :chrome, device: :desktop)
|
28
28
|
```
|
29
29
|
|
30
30
|
If you want to use proxies (note that proxy authentication is only possible using Poltergeist/PhantomJS):
|
data/bin/browse
CHANGED
@@ -4,8 +4,8 @@ require "bundler/setup"
|
|
4
4
|
require "browsed"
|
5
5
|
require "launchy"
|
6
6
|
|
7
|
-
driver = :
|
8
|
-
browser = :
|
7
|
+
driver = :selenium_chrome
|
8
|
+
browser = :chrome
|
9
9
|
|
10
10
|
url = "https://whatismyipaddress.com"
|
11
11
|
path = File.expand_path("../../files/#{Time.now.to_i}.png", __FILE__)
|
@@ -16,14 +16,10 @@ client = Browsed::Client.new(
|
|
16
16
|
device: :desktop,
|
17
17
|
environment: :development,
|
18
18
|
user_agent: :randomize,
|
19
|
-
resolution: [
|
19
|
+
resolution: [1920,1080]
|
20
20
|
)
|
21
21
|
|
22
22
|
client.resize! # Set resolution
|
23
|
-
|
24
23
|
client.session.visit(url)
|
25
|
-
|
26
|
-
|
27
|
-
client.session.save_screenshot(path)
|
28
|
-
client.display_screenshot!(path)
|
29
|
-
end
|
24
|
+
client.session.save_screenshot(path)
|
25
|
+
client.display_screenshot!(path)
|
data/browsed.gemspec
CHANGED
@@ -23,16 +23,16 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
-
spec.add_dependency "capybara", '~> 3.
|
26
|
+
spec.add_dependency "capybara", '~> 3.15'
|
27
27
|
spec.add_dependency "poltergeist", '~> 1.18', '>= 1.18.1'
|
28
|
-
spec.add_dependency "selenium-webdriver", '~> 3.
|
28
|
+
spec.add_dependency "selenium-webdriver", '~> 3.141'
|
29
29
|
|
30
30
|
spec.add_dependency "agents"
|
31
31
|
|
32
|
-
spec.add_development_dependency "bundler", "~> 1
|
33
|
-
spec.add_development_dependency "rake", "~>
|
34
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
spec.add_development_dependency "bundler", "~> 2.0.1"
|
33
|
+
spec.add_development_dependency "rake", "~> 12.3.2"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.8.0"
|
35
35
|
|
36
|
-
spec.add_development_dependency "pry", "~> 0.
|
36
|
+
spec.add_development_dependency "pry", "~> 0.12.2"
|
37
37
|
spec.add_development_dependency "launchy", '~> 2.4', '>= 2.4.3'
|
38
38
|
end
|
data/lib/browsed/chrome.rb
CHANGED
@@ -3,13 +3,19 @@ module Browsed
|
|
3
3
|
|
4
4
|
private
|
5
5
|
def register_chrome_driver(options: {}, timeout: 60, debug: false)
|
6
|
+
headless = options.fetch(:headless, false)
|
7
|
+
width = option.fetch(:width, 1920)
|
8
|
+
height = options.fetch(:height, 1080)
|
6
9
|
profile = Selenium::WebDriver::Chrome::Profile.new
|
7
10
|
|
8
11
|
profile["user-agent"] = self.user_agent unless self.user_agent.to_s.empty?
|
9
12
|
|
10
13
|
proxy_options = chrome_proxy_options
|
11
14
|
capabilities = !proxy_options.nil? ? Selenium::WebDriver::Remote::Capabilities.chrome(proxy: proxy_options) : {}
|
12
|
-
|
15
|
+
args = %W(disable-popup-blocking window-size=#{height},#{width})
|
16
|
+
args = args | %w(headless disable-gpu)
|
17
|
+
raise args.inspect
|
18
|
+
options = Selenium::WebDriver::Chrome::Options.new(profile: profile, args: args)
|
13
19
|
|
14
20
|
Capybara.register_driver self.driver do |app|
|
15
21
|
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options, desired_capabilities: capabilities)
|
data/lib/browsed/client.rb
CHANGED
@@ -9,8 +9,8 @@ module Browsed
|
|
9
9
|
include Capybara::DSL
|
10
10
|
|
11
11
|
def initialize(configuration: ::Browsed.configuration,
|
12
|
-
driver: :
|
13
|
-
browser: :
|
12
|
+
driver: :selenium_chrome,
|
13
|
+
browser: :chrome,
|
14
14
|
device: :desktop,
|
15
15
|
proxy: nil,
|
16
16
|
user_agent: nil,
|
@@ -72,7 +72,7 @@ module Browsed
|
|
72
72
|
def resize!(res = nil)
|
73
73
|
res ||= self.resolution
|
74
74
|
|
75
|
-
if res && res.size.eql?(2) && !self.driver.eql?(:poltergeist) #
|
75
|
+
if res && res.size.eql?(2) && !self.driver.eql?(:chrome) && !self.driver.eql?(:poltergeist) # Resolutions for Chrome & Poltergeist are set in the driver
|
76
76
|
self.session.current_window.resize_to(res.first, res.last) # [width, height]
|
77
77
|
end
|
78
78
|
end
|
@@ -112,6 +112,9 @@ module Browsed
|
|
112
112
|
elsif chrome_browser?
|
113
113
|
self.driver = :selenium_chrome
|
114
114
|
register_chrome_driver(options: options)
|
115
|
+
elsif chrome_headless_browser?
|
116
|
+
self.driver = :selenium_chrome_headless
|
117
|
+
register_chrome_driver(options: options.merge(headless: true))
|
115
118
|
end
|
116
119
|
end
|
117
120
|
end
|
@@ -136,6 +139,10 @@ module Browsed
|
|
136
139
|
self.browser.to_sym.eql?(:chrome)
|
137
140
|
end
|
138
141
|
|
142
|
+
def chrome_headless_browser?
|
143
|
+
self.browser.to_sym.eql?(:chrome_headless)
|
144
|
+
end
|
145
|
+
|
139
146
|
def development?
|
140
147
|
in_environment?(:development)
|
141
148
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
module Browsed
|
2
2
|
class Configuration
|
3
3
|
attr_accessor :driver, :browser, :environment
|
4
|
-
attr_accessor :
|
4
|
+
attr_accessor :binary_path, :download_path
|
5
5
|
attr_accessor :maximum_processes, :processes_max_ttl
|
6
6
|
attr_accessor :verbose
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
self.driver = :
|
10
|
-
self.browser = :
|
9
|
+
self.driver = :selenium_chrome
|
10
|
+
self.browser = :chrome
|
11
11
|
|
12
12
|
self.environment = :production
|
13
13
|
|
14
|
-
self.
|
14
|
+
self.binary_path = "/usr/local/bin/phantomjs"
|
15
15
|
|
16
16
|
self.download_path = nil
|
17
17
|
|
data/lib/browsed/poltergeist.rb
CHANGED
@@ -19,7 +19,7 @@ module Browsed
|
|
19
19
|
phantomjs_options: phantom_opts
|
20
20
|
}
|
21
21
|
|
22
|
-
options[:phantomjs] = self.configuration.
|
22
|
+
options[:phantomjs] = self.configuration.binary_path if in_environment?(:production)
|
23
23
|
options[:window_size] = self.resolution if self.resolution&.any?
|
24
24
|
|
25
25
|
headers = {}
|
data/lib/browsed/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browsed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 3.4.1
|
19
|
+
version: '3.15'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '3.
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 3.4.1
|
26
|
+
version: '3.15'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: poltergeist
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,20 +50,14 @@ dependencies:
|
|
56
50
|
requirements:
|
57
51
|
- - "~>"
|
58
52
|
- !ruby/object:Gem::Version
|
59
|
-
version: '3.
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 3.13.1
|
53
|
+
version: '3.141'
|
63
54
|
type: :runtime
|
64
55
|
prerelease: false
|
65
56
|
version_requirements: !ruby/object:Gem::Requirement
|
66
57
|
requirements:
|
67
58
|
- - "~>"
|
68
59
|
- !ruby/object:Gem::Version
|
69
|
-
version: '3.
|
70
|
-
- - ">="
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: 3.13.1
|
60
|
+
version: '3.141'
|
73
61
|
- !ruby/object:Gem::Dependency
|
74
62
|
name: agents
|
75
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,56 +78,56 @@ dependencies:
|
|
90
78
|
requirements:
|
91
79
|
- - "~>"
|
92
80
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
81
|
+
version: 2.0.1
|
94
82
|
type: :development
|
95
83
|
prerelease: false
|
96
84
|
version_requirements: !ruby/object:Gem::Requirement
|
97
85
|
requirements:
|
98
86
|
- - "~>"
|
99
87
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
88
|
+
version: 2.0.1
|
101
89
|
- !ruby/object:Gem::Dependency
|
102
90
|
name: rake
|
103
91
|
requirement: !ruby/object:Gem::Requirement
|
104
92
|
requirements:
|
105
93
|
- - "~>"
|
106
94
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
95
|
+
version: 12.3.2
|
108
96
|
type: :development
|
109
97
|
prerelease: false
|
110
98
|
version_requirements: !ruby/object:Gem::Requirement
|
111
99
|
requirements:
|
112
100
|
- - "~>"
|
113
101
|
- !ruby/object:Gem::Version
|
114
|
-
version:
|
102
|
+
version: 12.3.2
|
115
103
|
- !ruby/object:Gem::Dependency
|
116
104
|
name: rspec
|
117
105
|
requirement: !ruby/object:Gem::Requirement
|
118
106
|
requirements:
|
119
107
|
- - "~>"
|
120
108
|
- !ruby/object:Gem::Version
|
121
|
-
version:
|
109
|
+
version: 3.8.0
|
122
110
|
type: :development
|
123
111
|
prerelease: false
|
124
112
|
version_requirements: !ruby/object:Gem::Requirement
|
125
113
|
requirements:
|
126
114
|
- - "~>"
|
127
115
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
116
|
+
version: 3.8.0
|
129
117
|
- !ruby/object:Gem::Dependency
|
130
118
|
name: pry
|
131
119
|
requirement: !ruby/object:Gem::Requirement
|
132
120
|
requirements:
|
133
121
|
- - "~>"
|
134
122
|
- !ruby/object:Gem::Version
|
135
|
-
version: 0.
|
123
|
+
version: 0.12.2
|
136
124
|
type: :development
|
137
125
|
prerelease: false
|
138
126
|
version_requirements: !ruby/object:Gem::Requirement
|
139
127
|
requirements:
|
140
128
|
- - "~>"
|
141
129
|
- !ruby/object:Gem::Version
|
142
|
-
version: 0.
|
130
|
+
version: 0.12.2
|
143
131
|
- !ruby/object:Gem::Dependency
|
144
132
|
name: launchy
|
145
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -209,8 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
197
|
- !ruby/object:Gem::Version
|
210
198
|
version: '0'
|
211
199
|
requirements: []
|
212
|
-
|
213
|
-
rubygems_version: 2.7.7
|
200
|
+
rubygems_version: 3.0.3
|
214
201
|
signing_key:
|
215
202
|
specification_version: 4
|
216
203
|
summary: 'Browsed: Lightweight Capybara/PhantomJS/Selenium framework'
|