Permalink
Browse files

First commit: v0.1.0 :-)

  • Loading branch information...
0 parents commit 5565ad8fa2382ad79049721dbdf58746e24098e1 @chadrem committed Oct 8, 2011
@@ -0,0 +1,5 @@
+lib/**/*.rb
+bin/*
+-
+features/**/*.feature
+LICENSE.txt
@@ -0,0 +1,48 @@
+# rcov generated
+coverage
+
+# rdoc generated
+rdoc
+
+# yard generated
+doc
+.yardoc
+
+# bundler
+.bundle
+
+# jeweler generated
+pkg
+
+# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
+#
+# * Create a file at ~/.gitignore
+# * Include files you want ignored
+# * Run: git config --global core.excludesfile ~/.gitignore
+#
+# After doing this, these files will be ignored in all your git projects,
+# saving you from having to 'pollute' every project you touch with them
+#
+# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
+#
+# For MacOS:
+#
+#.DS_Store
+
+# For TextMate
+#*.tmproj
+#tmtags
+
+# For emacs:
+#*~
+#\#*
+#.\#*
+
+# For vim:
+#*.swp
+
+# For redcar:
+#.redcar
+
+# For rubinius:
+#*.rbc
1 .rspec
@@ -0,0 +1 @@
+--color
19 Gemfile
@@ -0,0 +1,19 @@
+source "http://rubygems.org"
+# Add dependencies required to use your gem here.
+# Example:
+# gem "activesupport", ">= 2.3.5"
+
+gem "typhoeus", "~> 0.2.4"
+gem "nokogiri", "~> 1.5.0"
+
+# Add dependencies to develop your gem here.
+# Include everything needed to run rake, tests, features, etc.
+group :development do
+ gem "rspec", "~> 2.3.0"
+ gem "bundler", "~> 1.0.0"
+ gem "jeweler", "~> 1.6.4"
+ gem "rcov", ">= 0"
+ gem "ZenTest", "~> 4.6.2"
+ gem "ruby-debug19", ">= 0.11.6", :require => "ruby-debug"
+ gem "rdoc", ">= 3.9.4"
+end
@@ -0,0 +1,54 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ ZenTest (4.6.2)
+ archive-tar-minitar (0.5.2)
+ columnize (0.3.4)
+ diff-lcs (1.1.3)
+ git (1.2.5)
+ jeweler (1.6.4)
+ bundler (~> 1.0)
+ git (>= 1.2.5)
+ rake
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
+ mime-types (1.16)
+ nokogiri (1.5.0)
+ rake (0.9.2)
+ rcov (0.9.10)
+ rdoc (3.9.4)
+ rspec (2.3.0)
+ rspec-core (~> 2.3.0)
+ rspec-expectations (~> 2.3.0)
+ rspec-mocks (~> 2.3.0)
+ rspec-core (2.3.1)
+ rspec-expectations (2.3.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.3.0)
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
+ typhoeus (0.2.4)
+ mime-types
+ mime-types
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ ZenTest (~> 4.6.2)
+ bundler (~> 1.0.0)
+ jeweler (~> 1.6.4)
+ nokogiri (~> 1.5.0)
+ rcov
+ rdoc (>= 3.9.4)
+ rspec (~> 2.3.0)
+ ruby-debug19 (>= 0.11.6)
+ typhoeus (~> 0.2.4)
@@ -0,0 +1,20 @@
+Copyright (c) 2011 Chad Remesch
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,61 @@
+URLs:
+- id can be one of the below IDs or an application ID which usually starts with com.
+- category is optional and works with a subset of the below IDs.
+https://market.android.com/details?id=&cat=
+https://market.android.com/details?id=com.angrymobgames.muffinknightfree
+
+Data Models:
+Android::Leaderboard
+Android::Leaderboard::Stat
+Android::App
+Android::App::Stat
+
+IDs:
+apps_topselling_paid
+apps_topselling_free
+apps_topselling_new_free
+apps_topselling_new_paid
+apps_editors_choice
+apps_topselling_paid_game
+apps_movers_shakers
+apps_featured
+apps_tablet_featured
+apps_topgrossing
+
+Categories:
+GAME
+ARCADE
+BRAIN
+CARDS
+CASUAL
+GAME_WALLPAPER
+RACING
+SPORTS_GAMES
+GAME_WIDGETS
+APPLICATION
+BOOKS_AND_REFERENCE
+BUSINESS
+COMICS
+COMMUNICATION
+EDUCATION
+ENTERTAINMENT
+FINANCE
+HEALTH_AND_FITNESS
+LIBRARIES_AND_DEMO
+LIFESTYLE
+APP_WALLPAPER
+MEDIA_AND_VIDEO
+MEDICAL
+MUSIC_AND_AUDIO
+NEWS_AND_MAGAZINES
+PERSONALIZATION
+PHOTOGRAPHY
+PRODUCTIVITY
+SHOPPING
+SOCIAL
+SPORTS
+TOOLS
+TRANSPORTATION
+TRAVEL_AND_LOCAL
+WEATHER
+APP_WIDGETS
@@ -0,0 +1,68 @@
+# Market Bot - High performance Ruby scraper for Google's Android Market
+
+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.
+
+## Dependencies
+
+* Nokogiri
+* Typhoeus
+
+## Installation
+
+ gem install market_bot
+
+## Usage Examples (parallel download method)
+
+ require 'rubygems'
+ require 'market_bot'
+
+ # Create a hydra object with 20 http workers.
+ hydra = Typhoeus::Hydra.new(:max_concurrency => 20)
+
+ # Download/parse the leaderboard.
+ lb = MarketBot::Android::Leaderboard.new(:apps_topselling_paid, :arcade, :hydra => hydra)
+ lb.enqueue_update
+ hydra.run
+
+ # Download/parse the details for the first and last entries of the leaderboard.
+ first_app = MarketBot::Android::App.new(lb.results.first[:market_id], :hydra => hydra)
+ last_app = MarketBot::Android::App.new(lb.results.last[:market_id], :hydra => hydra)
+ first_app.enqueue_update
+ last_app.enqueue_update
+ hydra.run
+
+ puts "First place app (#{first_app.title}) price: #{first_app.price}"
+ puts "Last place app (#{last_app.title}) price: #{last_app.price}"
+
+== Benchmarks
+
+Below are fairly typical results using 20 http workers (Typhoeus::Hydra.new(:max_concurrency => 20). The first benchmark downloads/parses a leaderboard containing 504 entries. The second benchmark takes those 504 entries, converts them to MarketBot::Android::App objects and then downloads/parses their details. Note that 20 workers are using to prevent DOSing the market servers. Higher values may work, but I don't recommend it.
+
+ $ rake benchmark:android
+ ----------------------------------------------------
+ Benchmark Leaderboard: Top Selling Paid Apps
+ ----------------------------------------------------
+ app count: 504
+ time: 3.16 seconds
+
+ ----------------------------------------------------
+ Benchmark Apps: top Selling Paid Apps
+ ----------------------------------------------------
+ app count: 504
+ time: 35.685 seconds
+
+## Contributing to Market Bot
+
+1. Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
+2. Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
+3. Fork the project.
+4. Start a feature/bugfix branch.
+5. Commit and push until you are happy with your contribution.
+6. Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
+7. Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
+
+## Copyright
+
+Copyright (c) 2011 Chad Remesch. See LICENSE.txt for
+further details.
+
114 Rakefile
@@ -0,0 +1,114 @@
+# encoding: utf-8
+
+require 'rubygems'
+require 'bundler'
+begin
+ Bundler.setup(:default, :development)
+rescue Bundler::BundlerError => e
+ $stderr.puts e.message
+ $stderr.puts "Run `bundle install` to install missing gems"
+ exit e.status_code
+end
+require 'rake'
+
+require 'jeweler'
+Jeweler::Tasks.new do |gem|
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
+ gem.name = "market_bot"
+ gem.homepage = "http://github.com/chadrem/market_bot"
+ gem.license = "MIT"
+ gem.summary = %Q{Market Bot: High performance Ruby scraper for Google's Android Market}
+ 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.}
+ gem.email = "chad@remesch.com"
+ gem.authors = ["Chad Remesch"]
+ # dependencies defined in Gemfile
+end
+Jeweler::RubygemsDotOrgTasks.new
+
+require 'rspec/core'
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new(:spec) do |spec|
+ spec.pattern = FileList['spec/**/*_spec.rb']
+end
+
+RSpec::Core::RakeTask.new(:rcov) do |spec|
+ spec.pattern = 'spec/**/*_spec.rb'
+ spec.rcov = true
+end
+
+task :default => :spec
+
+require 'rdoc/task'
+RDoc::Task.new do |rdoc|
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
+
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "market_bot #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+require 'typhoeus'
+
+namespace :spec do
+ namespace :data do
+ def download(url, save_path)
+ resp = Typhoeus::Request.get(url)
+ File.open(save_path, "w") do |file|
+ file.puts(resp.body)
+ end
+ end
+
+ desc 'download the latest test data used by the specs'
+ task :update do
+ download('https://market.android.com/details?id=com.bluefroggaming.popdat',
+ File.join(File.dirname(__FILE__), 'spec', 'market_bot', 'android', 'data', 'app_1.txt'))
+
+ download('https://market.android.com/details?id=apps_topselling_paid',
+ File.join(File.dirname(__FILE__), 'spec', 'market_bot', 'android', 'data', 'leaderboard-apps_topselling_paid-page1.txt'))
+
+ download('https://market.android.com/details?id=apps_topselling_paid&start=24&num=24',
+ File.join(File.dirname(__FILE__), 'spec', 'market_bot', 'android', 'data', 'leaderboard-apps_topselling_paid-page2.txt'))
+
+ download('https://market.android.com/details?id=apps_topselling_paid&start=48&num=24',
+ File.join(File.dirname(__FILE__), 'spec', 'market_bot', 'android', 'data', 'leaderboard-apps_topselling_paid-page3.txt'))
+
+ download('https://market.android.com/details?id=apps_topselling_paid&cat=ARCADE&start=1000&num=24',
+ File.join(File.dirname(__FILE__), 'spec', 'market_bot', 'android', 'data', 'leaderboard-apps_topselling_paid-page4.txt'))
+ end
+ end
+end
+
+namespace :benchmark do
+ task :android do
+ require 'market_bot'
+ require 'benchmark'
+
+ hydra = Typhoeus::Hydra.new(:max_concurrency => 20)
+
+ leaderboard = nil
+ leaderboard_ms = Benchmark.realtime {
+ leaderboard = MarketBot::Android::Leaderboard.new(:apps_topselling_paid, nil, :hydra => hydra)
+ leaderboard.update
+ }
+
+ puts '----------------------------------------------------'
+ puts 'Benchmark Leaderboard: Top Selling Paid Apps'
+ puts '----------------------------------------------------'
+ puts "app count: #{leaderboard.results.length}"
+ puts "time: #{leaderboard_ms.round(3)} seconds"
+ puts
+
+ apps = nil
+ apps_ms = Benchmark.realtime {
+ apps = leaderboard.results.map{ |r| MarketBot::Android::App.new(r[:market_id], :hydra => hydra).enqueue_update }
+ hydra.run
+ }
+
+ puts '----------------------------------------------------'
+ puts 'Benchmark Apps: top Selling Paid Apps'
+ puts '----------------------------------------------------'
+ puts "app count: #{apps.length}"
+ puts "time: #{apps_ms.round(3)} seconds"
+ end
+end
Oops, something went wrong.

0 comments on commit 5565ad8

Please sign in to comment.