browze 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +10 -0
- data/Guardfile +45 -0
- data/LICENSE.txt +21 -0
- data/README.md +69 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/browze.gemspec +32 -0
- data/lib/browze/client/desktop.rb +23 -0
- data/lib/browze/client/mobile.rb +19 -0
- data/lib/browze/client.rb +89 -0
- data/lib/browze/response.rb +35 -0
- data/lib/browze/version.rb +5 -0
- data/lib/browze.rb +17 -0
- metadata +171 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 72b282f5f06f2f9689bf7f5cff3b6f048673f423e034933aed3336d39b9605ce
|
|
4
|
+
data.tar.gz: 43b47d3e8cb2ca20390ed40f349cd8c65c53ebb382e6f56dfb736d5c4e2feffa
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3d16893d0da113ccc55de31d487bb39f7a8ed9378a457a4046ab692dda56d529f29457f3cf50e0389ed09d8dce376c686b2d8501f3649c5e2de35ae2ff7153ba
|
|
7
|
+
data.tar.gz: 62fb2a6483075b6199b80b3c6d63b5361690e36d3ddc31503568e50acb64bb6ae067d84b7640caf461af4d4d9f5c0f0b0d8bb64f621495dbce7d949a37fb9255
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# A sample Guardfile
|
|
4
|
+
# More info at https://github.com/guard/guard#readme
|
|
5
|
+
|
|
6
|
+
## Uncomment and set this to only include directories you want to watch
|
|
7
|
+
# directories %w(app lib config test spec features) \
|
|
8
|
+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
|
9
|
+
|
|
10
|
+
## Note: if you are using the `directories` clause above and you are not
|
|
11
|
+
## watching the project directory ('.'), then you will want to move
|
|
12
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
|
13
|
+
#
|
|
14
|
+
# $ mkdir config
|
|
15
|
+
# $ mv Guardfile config/
|
|
16
|
+
# $ ln -s config/Guardfile .
|
|
17
|
+
#
|
|
18
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
|
19
|
+
|
|
20
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
|
21
|
+
# rspec may be run, below are examples of the most common uses.
|
|
22
|
+
# * bundler: 'bundle exec rspec'
|
|
23
|
+
# * bundler binstubs: 'bin/rspec'
|
|
24
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
|
25
|
+
# installed the spring binstubs per the docs)
|
|
26
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
|
27
|
+
# * 'just' rspec: 'rspec'
|
|
28
|
+
|
|
29
|
+
guard :rspec, cmd: 'bundle exec rspec', failed_mode: :focus, all_after_pass: true do
|
|
30
|
+
require 'guard/rspec/dsl'
|
|
31
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
|
32
|
+
|
|
33
|
+
# Feel free to open issues for suggestions and improvements
|
|
34
|
+
|
|
35
|
+
# RSpec files
|
|
36
|
+
rspec = dsl.rspec
|
|
37
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
38
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
|
39
|
+
watch(rspec.spec_files)
|
|
40
|
+
|
|
41
|
+
# Ruby files
|
|
42
|
+
ruby = dsl.ruby
|
|
43
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
|
44
|
+
watch('lib/browze/client.rb') { 'spec/client' }
|
|
45
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Gianpiero Addis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Browze
|
|
2
|
+
|
|
3
|
+
A scraping-oriented browser-like wrapper around HTTParty for your cli tools.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'browze'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle install
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install browze
|
|
20
|
+
|
|
21
|
+
## Usage Examples
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
# Instantiate the browser
|
|
25
|
+
browser = Browze.start
|
|
26
|
+
|
|
27
|
+
# By default the browser is instantiated with a desktop user agent. if you want
|
|
28
|
+
# to use a mobile user agent instead, start it with :mobile.
|
|
29
|
+
mobile_browser = Browze.start(:mobile)
|
|
30
|
+
|
|
31
|
+
# A random user agent is set automatically
|
|
32
|
+
# e.g.: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
|
|
33
|
+
browser.user_agent
|
|
34
|
+
|
|
35
|
+
# Set any custom headers
|
|
36
|
+
browser.headers = { foo: 'bar' }
|
|
37
|
+
|
|
38
|
+
# Perform a GET request
|
|
39
|
+
response = browser.get('https://www.google.com/')
|
|
40
|
+
|
|
41
|
+
# Return the parsed response body as a Nokogiri::HTML::Document
|
|
42
|
+
response.parsed
|
|
43
|
+
|
|
44
|
+
# Perform a POST request
|
|
45
|
+
browser.post(
|
|
46
|
+
'https://www.example.com/url.php',
|
|
47
|
+
param1: 'example',
|
|
48
|
+
param2: 'example'
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Download a file and show a progress bar
|
|
52
|
+
browser.download('https://www.example.com/robots.txt')
|
|
53
|
+
|
|
54
|
+
# Show the current IP and geolocation
|
|
55
|
+
browser.ip # => 75.152.126.127
|
|
56
|
+
browser.location # => Grande Prairie, Canada
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Development
|
|
60
|
+
|
|
61
|
+
After checking out the repo, run `bundle install` to install dependencies. Then, run `bundle exec rspec` to run the specs or `bundle exec guard --clear` to keep them running during the development.
|
|
62
|
+
|
|
63
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
64
|
+
|
|
65
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "browze"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/browze.gemspec
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/browze/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'browze'
|
|
7
|
+
spec.version = Browze::VERSION
|
|
8
|
+
spec.authors = ['Gianpiero Addis']
|
|
9
|
+
|
|
10
|
+
spec.summary = 'A wrapper around HTTParty to quick start scraping tasks.'
|
|
11
|
+
spec.license = 'MIT'
|
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
|
13
|
+
|
|
14
|
+
# Specify which files should be added to the gem when it is released.
|
|
15
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
16
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
17
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
18
|
+
end
|
|
19
|
+
spec.bindir = 'exe'
|
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
21
|
+
spec.require_paths = ['lib']
|
|
22
|
+
|
|
23
|
+
spec.add_dependency 'down' # https://github.com/janko/down
|
|
24
|
+
spec.add_dependency 'geocoder' # https://github.com/alexreisner/geocoder
|
|
25
|
+
spec.add_dependency 'httparty' # https://github.com/jnunemaker/httparty
|
|
26
|
+
spec.add_dependency 'nokogiri' # https://github.com/sparklemotion/nokogiri
|
|
27
|
+
spec.add_dependency 'tty-progressbar' # https://github.com/piotrmurach/tty-progressbar
|
|
28
|
+
|
|
29
|
+
spec.add_development_dependency 'rspec-retry'
|
|
30
|
+
spec.add_development_dependency 'vcr'
|
|
31
|
+
spec.add_development_dependency 'webmock'
|
|
32
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Browze
|
|
4
|
+
class Client::Desktop < Browze::Client
|
|
5
|
+
# @return [Array] Most used desktop user agents.
|
|
6
|
+
USER_AGENTS = [
|
|
7
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
|
|
8
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36',
|
|
9
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15',
|
|
10
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',
|
|
11
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0',
|
|
12
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
|
|
13
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36',
|
|
14
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0',
|
|
15
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36',
|
|
16
|
+
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0',
|
|
17
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:76.0) Gecko/20100101 Firefox/76.0',
|
|
18
|
+
'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
|
|
19
|
+
'Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0',
|
|
20
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'
|
|
21
|
+
].freeze
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Browze
|
|
4
|
+
class Client::Mobile < Browze::Client
|
|
5
|
+
# @return [Array] Most used mobile user agents.
|
|
6
|
+
USER_AGENTS = [
|
|
7
|
+
'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1',
|
|
8
|
+
'Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; SCH-I535 Build/KOT49H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30',
|
|
9
|
+
'Mozilla/5.0 (Linux; Android 7.0; SM-G930V Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36',
|
|
10
|
+
'Mozilla/5.0 (Linux; Android 7.0; SM-A310F Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.91 Mobile Safari/537.36 OPR/42.7.2246.114996',
|
|
11
|
+
'Opera/9.80 (Android 4.1.2; Linux; Opera Mobi/ADR-1305251841) Presto/2.11.355 Version/12.10',
|
|
12
|
+
'Opera/9.80 (J2ME/MIDP; Opera Mini/5.1.21214/28.2725; U; ru) Presto/2.8.119 Version/11.10',
|
|
13
|
+
'Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) OPiOS/10.2.0.93022 Mobile/11D257 Safari/9537.53',
|
|
14
|
+
'Mozilla/5.0 (Android 7.0; Mobile; rv:54.0) Gecko/54.0 Firefox/54.0',
|
|
15
|
+
'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) FxiOS/7.5b3349 Mobile/14F89 Safari/603.2.4',
|
|
16
|
+
'Mozilla/5.0 (Linux; U; Android 7.0; en-US; SM-G935F Build/NRD90M) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/11.3.8.976 U3/0.8.0 Mobile Safari/534.30"'
|
|
17
|
+
].freeze
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'down'
|
|
4
|
+
require 'geocoder'
|
|
5
|
+
require 'httparty'
|
|
6
|
+
require 'fileutils'
|
|
7
|
+
require 'tty-progressbar'
|
|
8
|
+
|
|
9
|
+
module Browze
|
|
10
|
+
# Desktop and mobile clients inherit from the base client.
|
|
11
|
+
class Client
|
|
12
|
+
include HTTParty
|
|
13
|
+
|
|
14
|
+
attr_reader :cookies
|
|
15
|
+
attr_writer :headers
|
|
16
|
+
|
|
17
|
+
# Initialize the cookie jar and headers.
|
|
18
|
+
def initialize
|
|
19
|
+
@cookies = CookieHash.new
|
|
20
|
+
@headers = {}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Perform a GET request to the given url.
|
|
24
|
+
#
|
|
25
|
+
# @param [String] url
|
|
26
|
+
# @return [Browze::Response]
|
|
27
|
+
def get(url)
|
|
28
|
+
resp = Browze::Response.new(self.class.get(url, headers: headers))
|
|
29
|
+
resp.set_cookie.each { |c| @cookies.add_cookies(c) }
|
|
30
|
+
resp
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Perform a POST request to the given url with a request body.
|
|
34
|
+
#
|
|
35
|
+
# @param [String] url
|
|
36
|
+
# @param [Hash] body_hash
|
|
37
|
+
# @return [Browze::Response]
|
|
38
|
+
def post(url, body_hash)
|
|
39
|
+
resp = Browze::Response.new(self.class.post(url, body: body_hash, headers: headers))
|
|
40
|
+
resp.set_cookie.each { |c| @cookies.add_cookies(c) }
|
|
41
|
+
resp
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Download a file with an optional filename.
|
|
45
|
+
#
|
|
46
|
+
# @param [String] url
|
|
47
|
+
# @param [String] filename
|
|
48
|
+
def download(url, filename: nil)
|
|
49
|
+
bar = TTY::ProgressBar.new('Downloading... [:bar] :percent')
|
|
50
|
+
tempfile = Down.download(
|
|
51
|
+
url,
|
|
52
|
+
content_length_proc: ->(content_length) { bar.update(total: content_length) },
|
|
53
|
+
progress_proc: ->(progress) { bar.current = progress }
|
|
54
|
+
)
|
|
55
|
+
filename ||= tempfile.original_filename
|
|
56
|
+
FileUtils.mv(tempfile, filename)
|
|
57
|
+
puts "Download complete: #{filename} (#{tempfile.size} bytes)"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Get the updated headers.
|
|
61
|
+
#
|
|
62
|
+
# @return [Hash]
|
|
63
|
+
def headers
|
|
64
|
+
@headers.merge({ 'User-Agent' => user_agent, 'Cookie' => @cookies.to_cookie_string })
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Pick a random user agent and persist it in the instance.
|
|
68
|
+
#
|
|
69
|
+
# @return [String]
|
|
70
|
+
def user_agent
|
|
71
|
+
@user_agent ||= self.class::USER_AGENTS.sample
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Get the current public ip address.
|
|
75
|
+
#
|
|
76
|
+
# @return [String] the IP address
|
|
77
|
+
def ip
|
|
78
|
+
@ip ||= get('http://whatismyip.akamai.com').body
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Return the current location based on the public ip address.
|
|
82
|
+
#
|
|
83
|
+
# @return [String]
|
|
84
|
+
def location
|
|
85
|
+
l = Geocoder.search(ip).first
|
|
86
|
+
"#{l.city}, #{l.country}"
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'nokogiri'
|
|
4
|
+
|
|
5
|
+
module Browze
|
|
6
|
+
# Wrap the HTTParty response to assign custom attributes.
|
|
7
|
+
class Response
|
|
8
|
+
attr_reader :body,
|
|
9
|
+
:code,
|
|
10
|
+
:original
|
|
11
|
+
|
|
12
|
+
# Initialize the Response object with the original response data.
|
|
13
|
+
#
|
|
14
|
+
# @param [HTTParty::Response] response
|
|
15
|
+
def initialize(response)
|
|
16
|
+
@body = response.body
|
|
17
|
+
@code = response.code
|
|
18
|
+
@original = response
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Returns the response parsed with nokogiri.
|
|
22
|
+
#
|
|
23
|
+
# @return [Nokogiri::HTML4::Document]
|
|
24
|
+
def parsed
|
|
25
|
+
Nokogiri::HTML(body)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Get the cookies in the set-cookie header field.
|
|
29
|
+
#
|
|
30
|
+
# @return [Array] the cookies to be set in the client headers.
|
|
31
|
+
def set_cookie
|
|
32
|
+
original.get_fields('Set-Cookie') || []
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/browze.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'browze/version'
|
|
4
|
+
require 'browze/client'
|
|
5
|
+
require 'browze/client/mobile'
|
|
6
|
+
require 'browze/client/desktop'
|
|
7
|
+
require 'browze/response'
|
|
8
|
+
|
|
9
|
+
module Browze
|
|
10
|
+
# Create a new Browze instance.
|
|
11
|
+
#
|
|
12
|
+
# @param [Symbol] type
|
|
13
|
+
# @return [Browze::Client]
|
|
14
|
+
def self.start(type = :desktop)
|
|
15
|
+
type == :mobile ? Browze::Client::Mobile.new : Browze::Client::Desktop.new
|
|
16
|
+
end
|
|
17
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: browze
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Gianpiero Addis
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2021-12-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: down
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: geocoder
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: httparty
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: nokogiri
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: tty-progressbar
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rspec-retry
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: vcr
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: webmock
|
|
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'
|
|
125
|
+
description:
|
|
126
|
+
email:
|
|
127
|
+
executables: []
|
|
128
|
+
extensions: []
|
|
129
|
+
extra_rdoc_files: []
|
|
130
|
+
files:
|
|
131
|
+
- ".gitignore"
|
|
132
|
+
- ".rspec"
|
|
133
|
+
- ".travis.yml"
|
|
134
|
+
- Gemfile
|
|
135
|
+
- Guardfile
|
|
136
|
+
- LICENSE.txt
|
|
137
|
+
- README.md
|
|
138
|
+
- Rakefile
|
|
139
|
+
- bin/console
|
|
140
|
+
- bin/setup
|
|
141
|
+
- browze.gemspec
|
|
142
|
+
- lib/browze.rb
|
|
143
|
+
- lib/browze/client.rb
|
|
144
|
+
- lib/browze/client/desktop.rb
|
|
145
|
+
- lib/browze/client/mobile.rb
|
|
146
|
+
- lib/browze/response.rb
|
|
147
|
+
- lib/browze/version.rb
|
|
148
|
+
homepage:
|
|
149
|
+
licenses:
|
|
150
|
+
- MIT
|
|
151
|
+
metadata: {}
|
|
152
|
+
post_install_message:
|
|
153
|
+
rdoc_options: []
|
|
154
|
+
require_paths:
|
|
155
|
+
- lib
|
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
|
+
requirements:
|
|
158
|
+
- - ">="
|
|
159
|
+
- !ruby/object:Gem::Version
|
|
160
|
+
version: 2.3.0
|
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
|
+
requirements:
|
|
163
|
+
- - ">="
|
|
164
|
+
- !ruby/object:Gem::Version
|
|
165
|
+
version: '0'
|
|
166
|
+
requirements: []
|
|
167
|
+
rubygems_version: 3.0.3
|
|
168
|
+
signing_key:
|
|
169
|
+
specification_version: 4
|
|
170
|
+
summary: A wrapper around HTTParty to quick start scraping tasks.
|
|
171
|
+
test_files: []
|