market_bot 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9688ff41be35247c4bb0f85621bb800232111936
4
- data.tar.gz: 368e41730331ab5f6084ce49d6a51cbe87904d51
3
+ metadata.gz: b957c274ab5e86e3c0415b1af975ce4a115bbd78
4
+ data.tar.gz: 17e27abcbf8f10e5e9c338ece121d8067a4fb878
5
5
  SHA512:
6
- metadata.gz: 34de9be2e58bfeab53156bd5b3248fcd412918616431ab03b3521b5065f55d0b07deb913f7f08a07cf512b5151dc1c8859a5e52f70c1e1c84cd86a9129d57fd3
7
- data.tar.gz: 96e62fed37bee0a7ee35725a45470a3f912e7651e3868ae102f6135a7d6666e39abab95a76465e5849dafd86384745984bdebfb87949d792fbd50d11a393ef6a
6
+ metadata.gz: 226c78c540a1a8a4424e6a59839b89e50bf0b9e1390746e4df41c97fc8dade7811d8a3b2fc666930de1fb831c7faf8bef4c701ec9d79b8f0e7e1085f694ae033
7
+ data.tar.gz: bbdefb263e00eadc4b27aab602136a9222993b2868f9207c5a4612862483d47f6cbfc4c95c1655ffc8bcd8dffdab7b6bc793607dbe1e218af36ce23ea1356ca7
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ coverage
2
+ rdoc
3
+ doc
4
+ .yardoc
5
+ .bundle
6
+ pkg
7
+ .DS_Store
8
+ *.tmproj
9
+ tmtags
10
+ *~
11
+ \#*
12
+ .\#*
13
+ *.swp
14
+ .redcar
15
+ *.rbc
16
+ .rvmrc
17
+ vendor
18
+ .idea
19
+ .ruby-version
20
+ .ruby-gemset
21
+ vendor_bundle
data/Gemfile CHANGED
@@ -1,16 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
- gem 'typhoeus', '~> 0.4.2'
4
- gem 'nokogiri'
5
-
6
- group :development do
7
- gem 'rspec', '~> 2.8.0'
8
- gem 'bundler', '~> 1.3.0'
9
- gem 'jeweler', '~> 1.8.0'
10
- gem 'simplecov', '>= 0'
11
- gem 'rdoc', '>= 3.9.4'
12
- gem 'guard', '~> 1.2.3'
13
- gem 'guard-rspec', '~> 1.1.0'
14
- gem 'growl'
15
- platform(:ruby) { gem 'debugger' }
16
- end
3
+ # Specify your gem's dependencies in workers.gemspec
4
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,73 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ market_bot (0.11.0)
5
+ nokogiri
6
+ typhoeus (>= 0.6.0)
7
+
1
8
  GEM
2
- remote: http://rubygems.org/
9
+ remote: https://rubygems.org/
3
10
  specs:
4
- addressable (2.3.5)
5
- builder (3.2.2)
6
- columnize (0.3.6)
7
- debugger (1.6.1)
8
- columnize (>= 0.3.1)
9
- debugger-linecache (~> 1.2.0)
10
- debugger-ruby_core_source (~> 1.2.3)
11
- debugger-linecache (1.2.0)
12
- debugger-ruby_core_source (1.2.3)
13
11
  diff-lcs (1.1.3)
14
- faraday (0.8.7)
15
- multipart-post (~> 1.1)
16
- ffi (1.9.0)
17
- git (1.2.5)
18
- github_api (0.10.1)
19
- addressable
20
- faraday (~> 0.8.1)
21
- hashie (>= 1.2)
22
- multi_json (~> 1.4)
23
- nokogiri (~> 1.5.2)
24
- oauth2
25
- growl (1.0.3)
26
- guard (1.2.3)
27
- listen (>= 0.4.2)
28
- thor (>= 0.14.6)
29
- guard-rspec (1.1.0)
30
- guard (>= 1.1)
31
- hashie (2.0.5)
32
- highline (1.6.19)
33
- httpauth (0.2.0)
34
- jeweler (1.8.6)
35
- builder
36
- bundler (~> 1.0)
37
- git (>= 1.2.5)
38
- github_api (= 0.10.1)
39
- highline (>= 1.6.15)
40
- nokogiri (= 1.5.10)
41
- rake
42
- rdoc
43
- json (1.8.0)
44
- jwt (0.1.8)
45
- multi_json (>= 1.5)
46
- listen (1.2.2)
47
- rb-fsevent (>= 0.9.3)
48
- rb-inotify (>= 0.9)
49
- rb-kqueue (>= 0.2)
50
- mime-types (1.23)
51
- multi_json (1.7.7)
52
- multi_xml (0.5.4)
53
- multipart-post (1.2.0)
54
- nokogiri (1.5.10)
55
- oauth2 (0.9.2)
56
- faraday (~> 0.8)
57
- httpauth (~> 0.2)
58
- jwt (~> 0.1.4)
59
- multi_json (~> 1.0)
60
- multi_xml (~> 0.5)
61
- rack (~> 1.2)
62
- rack (1.5.2)
63
- rake (10.1.0)
64
- rb-fsevent (0.9.3)
65
- rb-inotify (0.9.0)
66
- ffi (>= 0.5.0)
67
- rb-kqueue (0.2.0)
68
- ffi (>= 0.5.0)
69
- rdoc (4.0.1)
70
- json (~> 1.4)
12
+ ethon (0.6.1)
13
+ ffi (>= 1.3.0)
14
+ mime-types (~> 1.18)
15
+ ffi (1.9.3)
16
+ mime-types (1.25.1)
17
+ mini_portile (0.5.2)
18
+ nokogiri (1.6.0)
19
+ mini_portile (~> 0.5.0)
71
20
  rspec (2.8.0)
72
21
  rspec-core (~> 2.8.0)
73
22
  rspec-expectations (~> 2.8.0)
@@ -76,27 +25,12 @@ GEM
76
25
  rspec-expectations (2.8.0)
77
26
  diff-lcs (~> 1.1.2)
78
27
  rspec-mocks (2.8.0)
79
- simplecov (0.7.1)
80
- multi_json (~> 1.0)
81
- simplecov-html (~> 0.7.1)
82
- simplecov-html (0.7.1)
83
- thor (0.18.1)
84
- typhoeus (0.4.2)
85
- ffi (~> 1.0)
86
- mime-types (~> 1.18)
28
+ typhoeus (0.6.6)
29
+ ethon (~> 0.6.1)
87
30
 
88
31
  PLATFORMS
89
32
  ruby
90
33
 
91
34
  DEPENDENCIES
92
- bundler (~> 1.3.0)
93
- debugger
94
- growl
95
- guard (~> 1.2.3)
96
- guard-rspec (~> 1.1.0)
97
- jeweler (~> 1.8.0)
98
- nokogiri
99
- rdoc (>= 3.9.4)
100
- rspec (~> 2.8.0)
101
- simplecov
102
- typhoeus (~> 0.4.2)
35
+ market_bot!
36
+ rspec (= 2.8.0)
data/README.markdown CHANGED
@@ -8,7 +8,7 @@ Used in production to power [www.droidmeter.com](http://www.droidmeter.com/?t=gi
8
8
 
9
9
  **This project is currently seeking developers to help maintain it.
10
10
  Please send pull requests or contact me if you are able to help out.
11
- The app scraper is known to work, but leader board functionality is currently broken.**
11
+ The app, leaderboard, and app search features are known to work, but the developer scraper is currently broken.**
12
12
 
13
13
  ## Dependencies
14
14
 
data/Rakefile CHANGED
@@ -1,29 +1,4 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "market_bot"
18
- gem.homepage = "http://github.com/chadrem/market_bot"
19
- gem.license = "MIT"
20
- gem.summary = %Q{Market Bot: High performance Ruby scraper for Google's Android Market}
21
- gem.description = %Q{Market Bot is a high performance Ruby scraper for Google's Android Market with a simple to use API. It is built on top of Nokogiri and Typhoeus.}
22
- gem.email = "chad@remesch.com"
23
- gem.authors = ["Chad Remesch"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
1
+ require 'bundler/gem_tasks'
27
2
 
28
3
  require 'rspec/core'
29
4
  require 'rspec/core/rake_task'
@@ -33,17 +8,17 @@ end
33
8
 
34
9
  task :default => :spec
35
10
 
36
- require 'rdoc/task'
37
- RDoc::Task.new do |rdoc|
38
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
11
+ desc 'Start an IRB console with Workers loaded'
12
+ task :console do
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
39
14
 
40
- rdoc.rdoc_dir = 'rdoc'
41
- rdoc.title = "market_bot #{version}"
42
- rdoc.rdoc_files.include('README*')
43
- rdoc.rdoc_files.include('lib/**/*.rb')
44
- end
15
+ require 'market_bot'
16
+ require 'irb'
45
17
 
46
- require 'typhoeus'
18
+ ARGV.clear
19
+
20
+ IRB.start
21
+ end
47
22
 
48
23
  namespace :spec do
49
24
  namespace :data do
@@ -63,19 +38,19 @@ namespace :spec do
63
38
  download('https://play.google.com/store/apps/details?id=com.evernote',
64
39
  File.join(File.dirname(__FILE__), 'spec', 'market_bot', 'android', 'data', 'app_2.txt'))
65
40
 
66
- download('https://play.google.com/store/apps/details?id=kooistar.solutions.Thermometer',
41
+ download('https://play.google.com/store/apps/details?id=com.mg.android',
67
42
  File.join(File.dirname(__FILE__), 'spec', 'market_bot', 'android', 'data', 'app_3.txt'))
68
43
 
69
- download('https://play.google.com/store/apps/collection/topselling_paid',
44
+ download('https://play.google.com/store/apps/category/ARCADE/collection/topselling_paid?num=24',
70
45
  File.join(File.dirname(__FILE__), 'spec', 'market_bot', 'android', 'data', 'leaderboard-apps_topselling_paid-page1.txt'))
71
46
 
72
- download('https://play.google.com/store/apps/collection/topselling_paid?start=24&num=24',
47
+ download('https://play.google.com/store/apps/category/ARCADE/collection/topselling_paid?start=24&num=24',
73
48
  File.join(File.dirname(__FILE__), 'spec', 'market_bot', 'android', 'data', 'leaderboard-apps_topselling_paid-page2.txt'))
74
49
 
75
- download('https://play.google.com/store/apps/collection/topselling_paid?start=48&num=24',
50
+ download('https://play.google.com/store/apps/category/ARCADE/collection/topselling_paid?start=48&num=24',
76
51
  File.join(File.dirname(__FILE__), 'spec', 'market_bot', 'android', 'data', 'leaderboard-apps_topselling_paid-page3.txt'))
77
52
 
78
- download('https://play.google.com/store/apps/collection/topselling_paid?start=456&num=24',
53
+ download('https://play.google.com/store/apps/category/ARCADE/collection/topselling_paid?start=96&num=24',
79
54
  File.join(File.dirname(__FILE__), 'spec', 'market_bot', 'android', 'data', 'leaderboard-apps_topselling_paid-page4.txt'))
80
55
 
81
56
  download('https://play.google.com/store/apps/collection/editors_choice',
data/lib/market_bot.rb CHANGED
@@ -3,6 +3,7 @@ require 'uri'
3
3
  require 'typhoeus'
4
4
  require 'nokogiri'
5
5
 
6
+ require 'market_bot/version'
6
7
  require 'market_bot/android/app'
7
8
  require 'market_bot/android/leaderboard/constants'
8
9
  require 'market_bot/android/leaderboard'
@@ -95,7 +95,7 @@ module MarketBot
95
95
  end
96
96
 
97
97
  result[:youtube_video_ids] = []
98
- doc.css('.play-click-target').each do |node|
98
+ doc.css('.play-action-container').each do |node|
99
99
  url = node['data-video-url']
100
100
  unless url.nil?
101
101
  result[:youtube_video_ids] << url.split('embed/').last.split('?').first
@@ -119,7 +119,7 @@ module MarketBot
119
119
  cur_index = 5
120
120
  %w(five four three two one).each do |slot|
121
121
  node = histogram.css(".#{slot.to_s}")
122
- result[:rating_distribution][cur_index] = node.css('.bar-number').text.to_i
122
+ result[:rating_distribution][cur_index] = node.css('.bar-number').text.gsub(/,/,'').to_i
123
123
  cur_index -= 1
124
124
 
125
125
  end
@@ -5,6 +5,9 @@ module MarketBot
5
5
  attr_reader :identifier, :category
6
6
  attr_reader :hydra
7
7
 
8
+ MAX_STARS = 5
9
+ PERCENT_DENOM = 100
10
+
8
11
  def self.parse(html)
9
12
  if html.include?('<title>Editor&#39;s Choice')
10
13
  parse_editors_choice_page(html)
@@ -17,25 +20,26 @@ module MarketBot
17
20
  results = []
18
21
  doc = Nokogiri::HTML(html)
19
22
 
20
- doc.css('.snippet').each do |snippet_node|
23
+ doc.css('.card').each do |snippet_node|
21
24
  result = {}
22
25
 
23
26
  details_node = snippet_node.css('.details')
24
27
 
25
- unless snippet_node.css('.ratings').empty?
26
- stars_text = snippet_node.css('.ratings').first.attributes['title'].value
27
- result[:stars] = /Rating: (.+) stars .*/.match(stars_text)[1]
28
+ unless snippet_node.css('.current-rating').empty?
29
+ stars_style = snippet_node.css('.current-rating').first.attributes['style'].value
30
+ stars_width_percent = stars_style[/width:\s+([0-9.]+)%/, 1].to_f
31
+ result[:stars] = (MAX_STARS * stars_width_percent/PERCENT_DENOM).round(1).to_s
28
32
  else
29
33
  result[:stars] = nil
30
34
  end
31
35
 
32
36
  result[:title] = details_node.css('.title').first.attributes['title'].to_s
33
37
 
34
- if (price_elem = details_node.css('.buy-button-price').children.first)
35
- result[:price_usd] = price_elem.text.gsub(' Buy', '')
38
+ if (price_elem = details_node.css('.buy span').first)
39
+ result[:price_usd] = price_elem.text
36
40
  end
37
41
 
38
- result[:developer] = details_node.css('.attribution').children.first.text
42
+ result[:developer] = details_node.css('.subtitle').first.attributes['title'].to_s
39
43
  result[:market_id] = details_node.css('.title').first.attributes['href'].to_s.gsub('/store/apps/details?id=', '').gsub(/&feature=.*$/, '')
40
44
  result[:market_url] = "https://play.google.com/store/apps/details?id=#{result[:market_id]}&hl=en"
41
45
 
@@ -0,0 +1,3 @@
1
+ module MarketBot
2
+ VERSION = '0.11.0'
3
+ end
data/market_bot.gemspec CHANGED
@@ -1,99 +1,23 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'market_bot/version'
5
5
 
6
- Gem::Specification.new do |s|
7
- s.name = "market_bot"
8
- s.version = "0.10.0"
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'market_bot'
8
+ gem.version = MarketBot::VERSION
9
+ gem.authors = ['Chad Remesch']
10
+ gem.email = ['chad@remesch.com']
11
+ gem.description = %q{Market Bot is a high performance Ruby scraper for Google's Android Market with a simple to use API. It is built on top of Nokogiri and Typhoeus.}
12
+ gem.summary = %q{Market Bot: High performance Ruby scraper for Google's Android Market}
13
+ gem.homepage = 'https://github.com/chadrem/market_bot'
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ['lib']
9
18
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Chad Remesch"]
12
- s.date = "2013-07-19"
13
- s.description = "Market Bot is a high performance Ruby scraper for Google's Android Market with a simple to use API. It is built on top of Nokogiri and Typhoeus."
14
- s.email = "chad@remesch.com"
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.markdown"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".rspec",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "Guardfile",
25
- "LICENSE.txt",
26
- "NOTES.txt",
27
- "README.markdown",
28
- "Rakefile",
29
- "VERSION",
30
- "lib/market_bot.rb",
31
- "lib/market_bot/android/app.rb",
32
- "lib/market_bot/android/developer.rb",
33
- "lib/market_bot/android/leaderboard.rb",
34
- "lib/market_bot/android/leaderboard/constants.rb",
35
- "lib/market_bot/android/search_query.rb",
36
- "market_bot.gemspec",
37
- "spec/market_bot/android/app_spec.rb",
38
- "spec/market_bot/android/data/app_1.txt",
39
- "spec/market_bot/android/data/app_2.txt",
40
- "spec/market_bot/android/data/app_3.txt",
41
- "spec/market_bot/android/data/leaderboard-apps_editors_choice.txt",
42
- "spec/market_bot/android/data/leaderboard-apps_topselling_paid-page1.txt",
43
- "spec/market_bot/android/data/leaderboard-apps_topselling_paid-page2.txt",
44
- "spec/market_bot/android/data/leaderboard-apps_topselling_paid-page3.txt",
45
- "spec/market_bot/android/data/leaderboard-apps_topselling_paid-page4.txt",
46
- "spec/market_bot/android/leaderboard_spec.rb",
47
- "spec/market_bot/android/search_query_spec.rb",
48
- "spec/market_bot_spec.rb",
49
- "spec/spec_helper.rb"
50
- ]
51
- s.homepage = "http://github.com/chadrem/market_bot"
52
- s.licenses = ["MIT"]
53
- s.require_paths = ["lib"]
54
- s.rubygems_version = "2.0.3"
55
- s.summary = "Market Bot: High performance Ruby scraper for Google's Android Market"
19
+ gem.add_dependency('typhoeus', '>= 0.6.0')
20
+ gem.add_dependency('nokogiri', '>= 0')
56
21
 
57
- if s.respond_to? :specification_version then
58
- s.specification_version = 4
59
-
60
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
- s.add_runtime_dependency(%q<typhoeus>, ["~> 0.4.2"])
62
- s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
63
- s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
64
- s.add_development_dependency(%q<bundler>, ["~> 1.3.0"])
65
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.0"])
66
- s.add_development_dependency(%q<simplecov>, [">= 0"])
67
- s.add_development_dependency(%q<rdoc>, [">= 3.9.4"])
68
- s.add_development_dependency(%q<guard>, ["~> 1.2.3"])
69
- s.add_development_dependency(%q<guard-rspec>, ["~> 1.1.0"])
70
- s.add_development_dependency(%q<growl>, [">= 0"])
71
- s.add_development_dependency(%q<debugger>, [">= 0"])
72
- else
73
- s.add_dependency(%q<typhoeus>, ["~> 0.4.2"])
74
- s.add_dependency(%q<nokogiri>, [">= 0"])
75
- s.add_dependency(%q<rspec>, ["~> 2.8.0"])
76
- s.add_dependency(%q<bundler>, ["~> 1.3.0"])
77
- s.add_dependency(%q<jeweler>, ["~> 1.8.0"])
78
- s.add_dependency(%q<simplecov>, [">= 0"])
79
- s.add_dependency(%q<rdoc>, [">= 3.9.4"])
80
- s.add_dependency(%q<guard>, ["~> 1.2.3"])
81
- s.add_dependency(%q<guard-rspec>, ["~> 1.1.0"])
82
- s.add_dependency(%q<growl>, [">= 0"])
83
- s.add_dependency(%q<debugger>, [">= 0"])
84
- end
85
- else
86
- s.add_dependency(%q<typhoeus>, ["~> 0.4.2"])
87
- s.add_dependency(%q<nokogiri>, [">= 0"])
88
- s.add_dependency(%q<rspec>, ["~> 2.8.0"])
89
- s.add_dependency(%q<bundler>, ["~> 1.3.0"])
90
- s.add_dependency(%q<jeweler>, ["~> 1.8.0"])
91
- s.add_dependency(%q<simplecov>, [">= 0"])
92
- s.add_dependency(%q<rdoc>, [">= 3.9.4"])
93
- s.add_dependency(%q<guard>, ["~> 1.2.3"])
94
- s.add_dependency(%q<guard-rspec>, ["~> 1.1.0"])
95
- s.add_dependency(%q<growl>, [">= 0"])
96
- s.add_dependency(%q<debugger>, [">= 0"])
97
- end
22
+ gem.add_development_dependency('rspec', '= 2.8.0')
98
23
  end
99
-